Пример #1
0
        public void GetSubscribedRooms(Tuple <int, string> socketDetails)
        {
            var    socketModelId = socketRepository.GetSocketId(socketDetails.Item1, socketDetails.Item2);
            string result        = "";

            if (socketModelId == 0)
            {
                var model = new SocketModel();
                model.IpAddress = socketDetails.Item2;
                model.Port      = socketDetails.Item1;
                model           = socketRepository.Insert(model);
                socketModelId   = model.Id;
                result          = "No subscribed rooms";
            }

            if (socketModelId != 0)
            {
                IList <RoomType> listOfRooms = clientRoomRepository.GetRoomsForClientId(socketModelId);
                if (listOfRooms != null && listOfRooms.Count > 0)
                {
                    result = "You are subscribed to the rooms: ";

                    foreach (var item in listOfRooms)
                    {
                        result += item.ToString();
                        result += " ";
                    }
                }
            }
            var buffer = Encoding.ASCII.GetBytes(result);
            // var sendBytes = socket.Send(buffer);
        }