public Client(Socket Soc, ListOfServers serverlist, ListOfLocalUsers clientlist, Core theCore) { soc = Soc; ServerList = serverlist; ClientList = clientlist; core = theCore; send = new SendMessage(ServerList, ClientList); }
// 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); }
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; }
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(); }
public User(Socket Soc, ListOfServers serverlist, ListOfLocalUsers clientlist, System.Collections.ArrayList myPlugins, Core thecore) : base(Soc, serverlist, clientlist, thecore) { Plugins = myPlugins; }
public userSendRecieve(Socket Soc, ListOfServers serverlist, ListOfLocalUsers clientlist, Core thecore) : base(Soc, serverlist, clientlist, thecore) { }
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) { }
public ServerWorkOutMessage(Socket Soc, ListOfServers serverlist, ListOfLocalUsers clientlist, Core thecore) : base(Soc, serverlist, clientlist, thecore) { usersToServer = new ListOfUsersToServer(); }
public ClientWorkOutMessage(Socket Soc, ListOfServers serverlist, ListOfLocalUsers clientlist, Core thecore) : base(Soc, serverlist, clientlist, thecore) { }
public SendMessage(ListOfServers servers, ListOfLocalUsers users) { allServers = servers; allLocalUsers = users; }