Struggling with multiplayer chatroom, but probably easy for someone more familiar with it

0 favourites
  • 6 posts
From the Asset Store
Easy Leaderboard is a simple 3-column (position, name, score) leaderboard with a customizable appearance
  • Hi everyone, so I'm working on a chat room and I have a few things that are probably easy but just not clicking for me. I'm attaching the project here for anyone who wants to take a look. i'm not changing much about the project.. the big change is simply to allow users to leave the chat room and come back in. This is working great.. but i have two major issues I'm trying to work out.

    1. When a user leaves the room.. others don't see the user leave.. but if the leaving user refreshes their browser, THEN the user disappears for everyone else. I can't find where the logical difference is.

    2. How do you properly use kick feature? I tried to use it and none of my efforts resulted in the user being ejected from the room. The multiplayer options all seem really straight forward so I must be missing something more subtle perhaps?

    It seems like you could simply grab the name of the person you need to kick and kick "username" and it would remove them.. but i feel like maybe there is further logic needed for it to work.

    here is a working example of it. you can actually join multiple times in the same browser with multiple tabs. https://part12studios.com/games/rd_bbs/rd_bbs_62/

    here is the file i'm working from right now.

    dropbox.com/s/g2ixbgaucqa6u21/BBS_Text%20%28updated%20original%29%20with%20exit%20button%203.zip

    I just don't get it.. it does seem like a "peer leaving room" is missing.. vs. "peer disconnected".. but also I just can't see what's going on that a peer refreshing their browser will register a "remove this guy" but my other conditions won't.

    And for the life of my, can't see how i could do it differently to insure any time a person leaves a room, their name disappears for everyone else.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Signaling server connection, room connection, and peer-host connection are all different things. You're looking for the multiplayer - room - disconnect action, which will disconnect the host from the peer (and leave the signaling room) not multiplayer - signaling - leave room.

    You can leave the signaling room (or even disconnect from signaling entirely) after making a connection with the host, and still be connected to the host. When you refresh/close your browser window you are finally closing that peer-host connection.

    Regarding the kick feature you need to use peerid, not the username.

  • oooo ok peerid.. i'll have to research that. that makes sense.. have to figure out how to find this peerid info..

    as for the other stuff.. it's just confusing as it seems like the terms kinda get interwoven.. but ok thanks for the insight! I'll read up on it and see if i can better understand how to properly call on these things.

    Thanks!

    Caleb

  • oosyrag ok I did some work in here for a bit.. definitely making more sense.. but i'm still having some trouble navigating the proper order of things.

    how do you get the user's peerid? as a host i just see their username in the peer list, not their peerid.. i can get my peerid (thanks for that clarity) so i got that far, but stuck.

    what i'd like to do is something like click the user name and extract the peerid to then be able to successfully kick that person by their peerid as you said..

  • PeerID is available as an expression in certain triggered multiplayer conditions like on peer connected and on message received. When used in those triggered events, it will give you the ID of the relevant peer.

    Normally you would store this in an instance variable in an object associated to that peer upon them connecting, but you can use any data structure you want, like a dictionary (key:value=name:PeerID) or an array.

    In the case of a chatroom, the simplest way would use a text object with an instance variable. Upon joining, set the text object to display the name of the user, and save the PeerID to an instance variable in that text object. Then for example if you clicked that name, it would be easy to get the associated PeerID.

    I would probably use a dictionary myself for flexibility, but that is a slight bit more complicated.

    Edit: You'll learn how to get and use PeerID better in the fourth multiplayer tutorial. That's why I'd recommended following and understanding all the multiplayer tutorials before using the multiplayer plugin, even if your end goal is just a chat room. The multiplayer plugin and multiplayer concepts are very complicated, so cutting corners will often lead to frustration in the future. The tutorials seem long, but they're actually quite concise and thorough.

  • yea i'll do that soon. I really want to understand this better and need to to make a proper chat room eventually.

    I think for now i'm going to do away with the peer list for my needs. it's nice but not required for the bbs look.

    just have a big chat room. the only thing i need to work out is how to send a "username" has left the chat room only when leaving, not disconnecting..

    even this is kinda optional, but this would do be a nice finishing touch to the most basic..

    Thanks for the perspective and insight! I didn't realize what i was jumping into. it looks so simple regarding the basic events, but i can see it has more under the surface.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)