示例#1
0
 public Client(Socket Soc, ListOfServers serverlist, ListOfLocalUsers clientlist, Core theCore)
 {
     soc        = Soc;
     ServerList = serverlist;
     ClientList = clientlist;
     core       = theCore;
     send       = new SendMessage(ServerList, ClientList);
 }
示例#2
0
        // returns -1 if faild and 1 if sucsess.
        public int Connect(int thePort)
        {
            port = thePort;
            // set up new instances of all veriables
            serverArray = new ListOfServers();
            clientArray = new ListOfLocalUsers();

            System.Net.IPEndPoint endpoint = new System.Net.IPEndPoint(System.Net.IPAddress.Any, port);
            serverSock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            System.GC.Collect();
            try
            {
                serverSock.Bind(endpoint);
            }
            catch (System.Exception)
            {
                serverArray = null;
                clientArray = null;
                endpoint    = null;
                serverSock  = null;

                return(-1);                // an error accound, most probs port is int use
            }

            serverSock.Listen(100);
            ServerState = true;

            // Setting up Threads //////////////////////////////////////////////////////////////////////
            connectionThread              = new System.Threading.Thread(new System.Threading.ThreadStart(AcceptLoop));
            connectionThread.Name         = "Accept Loop Thread";
            connectionThread.IsBackground = true;
            connectionThread.Start();

            DataRecievedThread              = new System.Threading.Thread(new System.Threading.ThreadStart(RecieveData));
            DataRecievedThread.Name         = "data recieved";
            DataRecievedThread.IsBackground = true;
            DataRecievedThread.Start();

            GCThread              = new System.Threading.Thread(new System.Threading.ThreadStart(GarbageCollection));
            GCThread.Name         = "GCThread";
            GCThread.IsBackground = true;
            GCThread.Start();

            endpoint = null;


            foreach (GHub.plugin.aPlugIn plug in myPlugins)
            {
                plug.PlugIn.ConnectionMade(serverArray, clientArray);
            }
            return(1);
        }
示例#3
0
 public userInfo(Socket Soc, ListOfServers serverlist, ListOfLocalUsers clientlist, Core thecore) : base(Soc, serverlist, clientlist, thecore)
 {
     rawInfo           = string.Empty;
     Description       = string.Empty;
     Tag               = string.Empty;
     EMail             = string.Empty;
     Connection        = string.Empty;
     Nick              = string.Empty;
     LoggedIn          = false;
     LoggedInCorrectly = false;
     SupportsSupport   = false;
     IsOP              = false;
 }
示例#4
0
        public void Disconnect()
        {
            ServerState = false;
            newConnection.Set();

            while (DataRecievedThread.ThreadState != System.Threading.ThreadState.Stopped)
            {
                System.Threading.Thread.Sleep(50);
            }

            while (connectionThread.ThreadState != System.Threading.ThreadState.Stopped)
            {
                System.Threading.Thread.Sleep(50);
            }

            mutexServerArray.WaitOne();
            mutexClientArray.WaitOne();

            serverArray.CloseAllSockets();
            clientArray.CloseAllSockets();

            mutexClientArray.ReleaseMutex();
            mutexServerArray.ReleaseMutex();

            //serverSock.Shutdown(System.Net.Sockets.SocketShutdown.Both);
            serverSock.Close();
            GHub.client.Client.ClearInfoList();
            GHub.Settings.ACCOUNTS.profiles.SaveToFile(1);
            GHub.Settings.ACCOUNTS.usersAccounts.SaveToFile(1);

            serverArray        = null;
            clientArray        = null;
            serverSock         = null;
            connectionThread   = null;
            DataRecievedThread = null;

            System.GC.Collect();
        }
示例#5
0
 public User(Socket Soc, ListOfServers serverlist, ListOfLocalUsers clientlist, System.Collections.ArrayList myPlugins, Core thecore) : base(Soc, serverlist, clientlist, thecore)
 {
     Plugins = myPlugins;
 }
示例#6
0
 public userSendRecieve(Socket Soc, ListOfServers serverlist, ListOfLocalUsers clientlist, Core thecore) : base(Soc, serverlist, clientlist, thecore)
 {
 }
示例#7
0
        private string serverName;         // a Uneek name used to identify this server.

        public serverInfo(Socket Soc, ListOfServers serverlist, ListOfLocalUsers clientlist, Core theCore) : base(Soc, serverlist, clientlist, theCore)
        {
        }
示例#8
0
 public ServerWorkOutMessage(Socket Soc, ListOfServers serverlist, ListOfLocalUsers clientlist, Core thecore) : base(Soc, serverlist, clientlist, thecore)
 {
     usersToServer = new ListOfUsersToServer();
 }
示例#9
0
 public ClientWorkOutMessage(Socket Soc, ListOfServers serverlist, ListOfLocalUsers clientlist, Core thecore) : base(Soc, serverlist, clientlist, thecore)
 {
 }
示例#10
0
 public SendMessage(ListOfServers servers, ListOfLocalUsers users)
 {
     allServers    = servers;
     allLocalUsers = users;
 }