Beispiel #1
0
        private void OnReceiveSessionJoinRequest(SharedSessionJoinRequest request, NebulaUser user)
        {
            SharedSessionRoom         room     = GetRoom(request.Session.Id);
            SharedSessionJoinResponse response = new SharedSessionJoinResponse();

            if (room == null)
            {
                response.ResponseCode = 10;
            }
            else
            {
                if (room.IsUserPresent(user))
                {
                    response.ResponseCode = 11;
                }
                else if (room.PasswordProtected && !room.VerifyPassword(request.Password))
                {
                    response.ResponseCode = 12;
                }
                else if (room.IsFull())
                {
                    response.ResponseCode = 13;
                }
                else
                {
                    room.AddUser(user);
                    response.ResponseCode = 0;
                    response.Session      = room.AsSessionInfo();
                    response.Users        = room.AsUsersArray();
                }
            }

            Server.SendPacket(response, user.Peer);
        }
Beispiel #2
0
        private async void OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (!(ListView.SelectedItem is SharedSessionInfo info))
            {
                return;
            }
            SharedSessionJoinRequest request = new SharedSessionJoinRequest {
                Session = info, Password = String.Empty
            };

            if (info.PasswordProtected)
            {
                SharedSessionJoinDialog dialog = new SharedSessionJoinDialog();
                await dialog.ShowDialogAsync();

                request.Password = dialog.RoomPassword;
            }

            NebulaClient.Network.SendPacket(request);
        }