protected override void OnReceive(object message)
        {
            switch (message)
            {
            case Say s:
                Publish(s);
                break;

            case JoinRoom j:
                _users[Sender] = j.UserName;
                Context.Watch(Sender);
                Publish(new SystemMsg($"{j.UserName} has joined {_roomName}"));
                break;

            case LeaveRoom l:
                Context.Unwatch(Sender);
                var user = _users[Sender];
                Publish(new SystemMsg($"{user} has left {_roomName}"));
                _users.Remove(Sender);
                var left = new LeftRoom(_roomName);
                _receptionist.Tell(left);
                Sender.Tell(left);
                break;

            case Terminated t:     // client abruptly terminated
                _users.Remove(t.ActorRef);
                _receptionist.Tell(new LeftRoom(_roomName));
                break;

            default:
                Unhandled(message);
                break;
            }
        }
Exemple #2
0
 public void OnLeftRoom()
 {
     if (LeftRoom != null)
     {
         LeftRoom.Invoke(this);
     }
 }
Exemple #3
0
        public void Handle(LeftRoom message)
        {
            var leftRoom = message.Room;
            var link     = this.chatGroup.Links.OfType <RoomLink>().FirstOrDefault(r => r.RoomName == leftRoom.Name);

            this.chatGroup.Links.Remove(link);

            var navigationLink = this.chatGroup.Links.FirstOrDefault();

            this.ContentSource = navigationLink.Source;
        }
Exemple #4
0
    public override void PushB()
    {
        int pullAmount = MaxEnergy - Energy;
        int actualPull = 0;

        Room pullFromRoom = LeftRoom;

        if (pullFromRoom == null)
        {
            pullFromRoom = RightRoom;
        }

        actualPull = LeftRoom.TryPullEnergy(pullAmount);
        Energy    += actualPull;
    }
Exemple #5
0
 public void OnClientLeftRoom(Room _room)
 {
     LeftRoom?.Invoke(_room);
 }
Exemple #6
0
 public void OnLeftRoom(object sender, PersonModel person, RoomModel room)
 {
     LeftRoom?.Invoke(sender, new RoomAttendanceEventArgs(person, room));
 }
Exemple #7
0
 internal void OnLeftRoom()
 {
     LeftRoom?.Invoke();
 }