/// <summary>Creates a new ClientConnexion to communicate with.</summary> /// <param name="s">The associated server instance.</param> /// <param name="clientGuid">A globally unique identifier for the associated client.</param> /// <param name="clientIdentity">The server-unique identity of this new client's connexion.</param> public ConnexionToClient(Server s, Guid clientGuid, int clientIdentity) { owner = s; this.clientGuid = clientGuid; identity = clientIdentity; active = true; }
public void TestServerRestarting() { Server server = new Server(0); server.Start(); server.Stop(); server.ToString(); // shouldn't throw an exception server.Start(); server.Stop(); server.Dispose(); server.ToString(); }
/// <summary> /// Check an incoming connection; if the connection is deemed to be /// invalid, then return a descriptive reason. /// </summary> /// <param name="server">the server instance</param> /// <param name="transport">the transport in question</param> /// <param name="capabilities">the capabilities from the remote</param> /// <returns>null if valid, a reason if invalid</returns> public virtual string ValidateIncomingTransport(Server server, ITransport transport, IDictionary<string, string> capabilities) { if(!capabilities.ContainsKey(GTCapabilities.MARSHALLER_DESCRIPTORS)) { return "no marshaller capabilities provided"; } if(!server.Marshaller.IsCompatible(capabilities[GTCapabilities.MARSHALLER_DESCRIPTORS], transport)) { return "incompatible marshaller"; } return null; }
/// <summary> /// Create an connexion representing the client. /// </summary> /// <param name="owner">the associated server instance</param> /// <param name="clientGuid">the client's GUID</param> /// <param name="clientIdentity">the server-unique identity for the client</param> /// <returns>the client connexion</returns> public virtual IConnexion CreateClientConnexion(Server owner, Guid clientGuid, int clientIdentity) { return new ConnexionToClient(owner, clientGuid, clientIdentity); }
/// <summary> /// Start the client-repeater instance. /// </summary> /// <remarks> /// Note: the behaviour of this method was changed with GT 3.0 /// such that a new thread is no longer launched for handling incoming /// messages. Callers desiring this behaviour should call <see cref="StartSeparateListeningThread"/> /// instead. /// </remarks> public void Start() { if (server == null) { server = config.BuildServer(); server.MessageReceived += s_MessageReceived; server.ClientsJoined += s_ClientsJoined; server.ClientsRemoved += s_ClientsRemoved; server.ErrorEvent += s_ErrorEvent; // Some transports are unreliable, meaning that we cannot tell whether // a remote has stopped communicating because they have shutdown ungracefully // (e.g., crashed), because the network is down, or because they haven't // sent a reply. The PingBasedDisconnector uses the ping response time // to automatically drop inactive connections. if (InactiveTransportTimeout.TotalSeconds > 0) { pbd = new PingBasedDisconnector(server, InactiveTransportTimeout); pbd.ErrorEvent += s_ErrorEvent; } } if(!server.Active) { server.Start(); if (pbd != null) { pbd.Start(); } } }
public void Dispose() { Stop(); if (server != null) { server.Dispose(); } server = null; }
public BBServer(ushort port) { server = new GT.Net.Server(new DefaultServerConfiguration(port)); server.ObjectMessageReceived += _server_ObjectReceived; server.ClientsJoined += _server_NewClients; }