public static ServerProperty getInstance()
 {
     if (instance == null)
     {
         instance = new ServerProperty();
     }
     return(instance);
 }
Ejemplo n.º 2
0
        public void Dispose()
        {
            ServerProperty sp = ServerProperty.getInstance();

            if (client != null)
            {
                client.Close();
            }

            if (ChannelNumber != -1)
            {
                User temp;
                PackedData.RoomMember temp2;

                sp.channelsList[ChannelNumber].users.TryRemove(Nickname, out temp);

                try
                {
                    if (RoomID == Nickname)
                    {
                        foreach (KeyValuePair <string, PackedData.RoomMember> u in sp.channelsList[ChannelNumber].rooms[RoomID].members)
                        {
                            MessageHandler.SendToUser(
                                sp.channelsList[ChannelNumber].users[u.Value.Nickname],
                                CustomProtocolManager.MakeRoomResponsePacket()
                                );
                        }
                        Room dummy;
                        sp.channelsList[ChannelNumber].rooms.TryRemove(RoomID, out dummy);
                    }
                    else if (RoomID != null)
                    {
                        sp.channelsList[ChannelNumber].rooms[RoomID].members.TryRemove(Nickname, out temp2);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("user.Dispose: " + e.Message);
                }
            }


            Id       = null;
            Nickname = null;
        }