コード例 #1
0
        private void Service_ConnectionOpenedOrClosed(ConnectionAction action, SyncService s)
        {
            if (action == ConnectionAction.OPENED)
            {
                Logger.Log("Client [{0}] connected. {1} clients online in room {2}.", s.Nickname, Services.Count, RoomCode);

                if (CurrentQueue.URLs != null)
                {
                    // update new user with queue
                    var res = new
                    {
                        CommandType = CommandType.QUEUEUPDATE.Value,
                        Queue       = new
                        {
                            Name       = CurrentQueue.Name,
                            QueueIndex = CurrentQueue.QueueIndex,
                            URLs       = CurrentQueue.URLs
                        }
                    };

                    s.SendMessage(JsonConvert.SerializeObject(res));
                }


                // notify service of their nickname
                var res1 = new
                {
                    CommandType = CommandType.SETUSERNICKNAME.Value,
                    Nickname    = s.Nickname
                };

                s.SendMessage(JsonConvert.SerializeObject(res1));


                // notify service of like count
                var res2 = new
                {
                    CommandType = CommandType.UPDATELIKES.Value,
                    Likes       = likes
                };

                s.SendMessage(JsonConvert.SerializeObject(res2));
            }
            else
            {
                int index = Services.FindIndex(x => x.ID == s.ID);
                Services.RemoveAt(index);
                Logger.Log("Client [{0}] disconnected. {1} clients online in room {2}.", s.Nickname, Services.Count, RoomCode);
            }


            ActiveUsers = Services.Count;
            ReassessOwnership(s, action);

            SendUserList();
        }
コード例 #2
0
 public void BroadcastExcept(string message, SyncService exception)
 {
     for (int i = 0; i < Services.Count; i++)
     {
         if (Services[i].ID != exception.ID)
         {
             Services[i].SendMessage(message);
         }
     }
 }
コード例 #3
0
 private void Service_MessageRecieved(dynamic message, SyncService s)
 {
     RecievedCommandInterpreter.InterpretCommand(message, s, this);
 }