Beispiel #1
0
 private void UserJoinHandler(UserJoin userJoin)
 {
     ChatUserInfos.Add(new ChatUserInfo()
     {
         UserName = userJoin.UserName
     });
 }
Beispiel #2
0
        public async Task UserJoinMessage(UserJoin userJoin)
        {
            var user = _game.AddUser(userJoin);

            ClientToUser[Context.ConnectionId] = user;

            await Clients.All.SendAsync(MessageKey.UserJoin, user);
        }
        private void UserJoinHandler(byte[] data)
        {
            UserJoin userJoin = NetworkUtils.Deserialize <UserJoin>(data);

            Application.Current.Dispatcher.BeginInvoke(new Action(() => {
                UserJoinEvent?.Invoke(userJoin);
            }));
        }
Beispiel #4
0
        public void LoadEvents()
        {
            Client.UserJoined += async(u) =>
            {
                Task.Run(() => UserJoin?.Invoke(new RuntimeUser(u)));
            };

            Client.UserLeft += async(u) =>
            {
                Task.Run(() => UserLeft?.Invoke(new RuntimeUser(u)));
            };

            Client.UserUpdated += async(u, unew) =>
            {
                RuntimeUser userOld = new RuntimeUser(u);
                RuntimeUser userNew = new RuntimeUser(unew);
                Task.Run(() => UserUpdated?.Invoke(userOld, userNew));
            };

            Client.MessageReceived += async(m) =>
            {
                RuntimeMessage newMessage = new RuntimeMessage(m);
                if (MessageReceived != null)
                {
                    await MessageReceived.Invoke(newMessage);
                }
            };

            Client.JoinedGuild += async(g) =>
            {
                Task.Run(async() =>
                {
                    RuntimeGuild guild = new RuntimeGuild(g);
                    await GuildJoin?.Invoke(guild);
                });
            };

            Client.LeftGuild += async(g) =>
            {
                RuntimeGuild guild = new RuntimeGuild(g);
                await GuildLeave?.Invoke(guild);
            };

            foreach (var shard in Client.Shards)
            {
                shard.Disconnected += async(ex) =>
                {
                    await OnShardDisconnect?.Invoke(ex, shard.ShardId);
                };
                shard.Connected += async() =>
                {
                    if (OnShardConnect != null)
                    {
                        await OnShardConnect.Invoke(shard.ShardId);
                    }
                };
            }
        }
Beispiel #5
0
        private void UserJoinHandler(Socket socket, byte[] data)
        {
            UserJoin userJoin = NetworkUtils.Deserialize <UserJoin>(data);

            chatRoom.UserJoin(new ChatUser()
            {
                socket   = socket,
                userName = userJoin.UserName
            });
        }
        public async Task UserLeaveHttpTest()
        {
            HttpClient client = new HttpClient();
            UserJoin   leave  = new UserJoin(Guid.Parse("9AEBDC07-593A-4345-89DD-7C1E8BA155DF"), Guid.Parse("62978E72-14C0-4A95-AEC0-F3489ABF8972"));

            var result = await client.PostAsJsonAsync($"http://localhost:60253/api/User/Leave", leave);

            string response = await result.Content.ReadAsStringAsync();

            var leaveResponse = JsonConvert.DeserializeObject <bool>(response);

            Assert.IsNotNull(leaveResponse);
        }
Beispiel #7
0
        public void BasicUserJoinHasNavProperties()
        {
            var conn1 = new Connector();
            var conn2 = new Connector();

            UserJoin userJoin = new UserJoin
            {
                PKConnector = conn1,
                FKConnector = conn2
            };

            Assert.AreEqual(conn1, userJoin.PKConnector);
            Assert.AreEqual(conn2, userJoin.FKConnector);
        }
Beispiel #8
0
        public User AddUser(UserJoin userJoin)
        {
            var user = new User
            {
                Direction = Direction.Up,
                Name      = userJoin.Name,
                UserId    = userJoin.UserId
            };

            lock (_stateLock)
            {
                _state.Users.Add(user);
            }

            return(user);
        }
        /// <summary>
        /// Join a join drive
        /// </summary>
        /// <param name="driveId"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public async Task JoinJDrive(int driveId, int userId)
        {
            var userJoin = new UserJoin
            {
                DriveId = driveId,
                UserId  = userId
            };

            try
            {
                bbBContext.Add(userJoin);
                await bbBContext.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                logger.Info(ex);
                throw;
            }
        }
Beispiel #10
0
        public void LoadEvents()
        {
            Client.UserJoined += async(u) =>
            {
                await MeruUtils.TryAsync(async() =>
                {
                    Task.Run(() => UserJoin?.Invoke(new RuntimeUser(u)));
                });
            };

            Client.UserLeft += async(u) =>
            {
                await MeruUtils.TryAsync(async() =>
                {
                    Task.Run(() => UserLeft?.Invoke(new RuntimeUser(u)));
                });
            };

            Client.UserUpdated += async(u, unew) =>
            {
                RuntimeUser userOld = new RuntimeUser(u);
                RuntimeUser userNew = new RuntimeUser(unew);
                Task.Run(() => UserUpdated?.Invoke(userOld, userNew));
            };

            Client.MessageReceived += async(m) =>
            {
                Task.Run(async() =>
                {
                    await MeruUtils.TryAsync(async() =>
                    {
                        RuntimeMessage newMessage = new RuntimeMessage(m);
                        await MessageReceived?.Invoke(newMessage);
                    });
                });
            };
        }
Beispiel #11
0
        public bool Join([FromBody] UserJoin userJoin)
        {
            DataTable table = new DataTable();

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                using (SqlCommand command = new SqlCommand("usp_playerJoin", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.Add(new SqlParameter("@PublicRoomId", userJoin.PublicRoomId));
                    command.Parameters.Add(new SqlParameter("@PublicJoinedId", userJoin.PublicUserId));

                    SqlDataAdapter adapter = new SqlDataAdapter(command);
                    adapter.Fill(table);
                }
            }

            if (table.Rows.Count == 0)
            {
                return(true);
            }

            return(false);
        }
Beispiel #12
0
 private void InvokeUserJoinEvent(User user)
 {
     UserJoin?.Invoke(this, user);
 }
Beispiel #13
0
 public void OnUserJoin(User u)
 {
     UserJoin?.Invoke(this, u);
 }
Beispiel #14
0
 public UserGroup()
 {
     memberList              = new NCList <T>();
     memberList.ItemAdded   += a => { UserJoin?.Invoke(a); };
     memberList.ItemRemoved += a => { UserExit?.Invoke(a); };
 }
Beispiel #15
0
 internal void OnUserJoin(JoinMessage message) => UserJoin?.Invoke(message);