Ejemplo n.º 1
0
        void EngineRoomUserUpdate(object sender, RoomUserUpdateEventArgs e)
        {
            var roomUserUpdateEvent = e.Event;

            var user = UserManager.FindByName(roomUserUpdateEvent.UserName);
            var room = RoomManager.FindById(roomUserUpdateEvent.RoomId);

            if (user == null)
            {
                user = new ClientUser {
                    UserName = roomUserUpdateEvent.UserName
                };
                //foreach (UserVariable current in roomUserUpdateEvent.UserVariables)
                //{
                //    user.AddUserVariable(current);
                //}
            }

            switch (roomUserUpdateEvent.Action)
            {
            case RoomUserUpdateAction.AddUser:
                user = UserManager.AddUser(user);
                room.AddUser(user);
                break;

            case RoomUserUpdateAction.DeleteUser:
                UserManager.RemoveUser(user.UserName);
                room.RemoveUser(user);
                break;
            }
        }
Ejemplo n.º 2
0
        void EngineJoinRoom(object sender, JoinRoomEventArgs e)
        {
            var joinRoomEvent = e.Event;

            if (RoomManager == null)
            {
                return;
            }

            var room = RoomManager.FindById(joinRoomEvent.RoomId);

            if (room == null)
            {
                room = new ClientRoom(joinRoomEvent.RoomId)
                {
                    Name = joinRoomEvent.RoomName
                };
                RoomManager.AddRoom(room);
            }

            room.Description = joinRoomEvent.RoomDescription;
            room.IsProtected = joinRoomEvent.Protected;
            room.Capacity    = joinRoomEvent.Capacity;
            room.IsHidden    = joinRoomEvent.Hidden;

            //foreach (SharedObject roomVariable in joinRoomEvent.RoomVariables)
            //{
            //    room.AddRoomVariable(roomVariable.Name, roomVariable);
            //}

            foreach (var userListEntry in joinRoomEvent.Users)
            {
                var u = UserManager.AddUser(UserListEntryToUser(userListEntry));
                room.AddUser(u);
            }

            if (UserManager != null)
            {
                UserManager.Me.Room = room;
            }
        }