// constructors public ServerFactory(ServerSettings settings, IConnectionPoolFactory connectionPoolFactory, IConnectionFactory heartbeatConnectionFactory, IServerListener listener) { _settings = Ensure.IsNotNull(settings, "settings"); _connectionPoolFactory = Ensure.IsNotNull(connectionPoolFactory, "connectionPoolFactory"); _heartbeatConnectionFactory = Ensure.IsNotNull(heartbeatConnectionFactory, "heartbeatConnectionFactory"); _listener = listener; }
public void RemoveListener(IServerListener listener) { if (_listeners.Contains(listener)) { _listeners.Remove(listener); } }
public ClusterBuilder AddListener(IListener listener) { var clusterListener = listener as IClusterListener; if (clusterListener != null) { _clusterListener = ClusterListenerPair.Create(_clusterListener, clusterListener); } var serverListener = listener as IServerListener; if (serverListener != null) { _serverListener = ServerListenerPair.Create(_serverListener, serverListener); } var connectionPoolListener = listener as IConnectionPoolListener; if (connectionPoolListener != null) { _connectionPoolListener = ConnectionPoolListenerPair.Create(_connectionPoolListener, connectionPoolListener); } var connectionListener = listener as IConnectionListener; if (connectionListener != null) { _connectionListener = ConnectionListenerPair.Create(_connectionListener, connectionListener); } return(this); }
internal ServerManager(ConnectionInfo info, IServerListener asyncListener) { this.connInfo = info; this.localPushServerProxy = new PushServerProxy(info); this.activityController = new ActivityController(this); this.serverListener = asyncListener; }
public void AddListener(IServerListener listener) { if (!_listeners.Contains(listener)) { _listeners.Add(listener); } }
internal ServerManager(ConnectionInfo info, IConnectionListener listener, IServerListener asyncListener) { Stream stream = null; this.probeTimeoutMillis = info.probeTimeoutMillis; this.probeWarningMillis = info.probeWarningMillis; this.reconnectionTimeoutMillis = info.reconnectionTimeoutMillis; this.localPushServerProxy = new PushServerProxy(info); try { stream = this.localPushServerProxy.ConnectForSession(); try { listener.OnConnectionEstablished(); } catch (Exception) { } this.localPushServerProxy.StartSession(stream); try { listener.OnSessionStarted(); } catch (Exception) { } } catch (PhaseException) { } this.serverListener = asyncListener; }
public ModuleServeur(IServerListener listener) { _moduleLister = listener; _listOfClientsThread = new List <Thread>(); _waitingForClient = false; _running = false; _counter = 0; }
internal ServerManager(ConnectionInfo info, IServerListener asyncListener) { this.connInfo = info; this.localPushServerProxy = new PushServerProxy(info); this.activityController = new ActivityController(this); this.mexParallelizer = new MessageParallelizer(this.mexBatchMonitor, this); this.serverListener = asyncListener; }
public void Close() { _running = false; clientList = null; listener = null; serializer = null; serverSettings = new ServerOptions(); }
public override void Shutdown() { base.Shutdown(); if (mServerListener != null) { mServerListener.Dispose(); mServerListener = null; } }
public void Open(IPAddress ip, int port) { if (m_ServerListener != null) { throw new InvalidOperationException("Server was already started."); } m_ServerListener = new TcpServerListener(OnServiceRequest); m_ServerListener.Start(ip, port); }
public void Setup() { _clusterId = new ClusterId(); _connectionPoolFactory = Substitute.For <IConnectionPoolFactory>(); _endPoint = new DnsEndPoint("localhost", 27017); _heartbeatConnectionFactory = Substitute.For <IConnectionFactory>(); _listener = Substitute.For <IServerListener>(); _settings = new ServerSettings(); }
public override IEnumerator PostInitialize() { #if !UNITY_WEBGL || UNITY_EDITOR // 无法在WEBLGL本地端上创建服务器 mServerListener = new ScratchServerConnection(); if (mServerListener != null) { // mServerListener.StartListener(hostSettingRef.GetHost("server")); } #endif yield break; }
public void StartServer() { _listener = new AsyncSocketListener(); _clientVM = (ClientInfoViewModel)ListViewClients.DataContext; _clientVM.Listener = _listener; BindEvents(); //new Thread(() => //{ // Thread.CurrentThread.IsBackground = true; //_listener.StartListening("127.0.0.1", 13000); _listener.StartListening("192.168.1.106", 13000); //}).Start(); }
// static /// <summary> /// Combines two server listeners. /// </summary> /// <param name="first">The first server listener, or null.</param> /// <param name="second">The second server listener, or null.</param> /// <returns>A combined server listener.</returns> public static IServerListener Create(IServerListener first, IServerListener second) { if (first == null) { return(second); } if (second == null) { return(first); } return(new ServerListenerPair(first, second)); }
// static public static IServerListener Create(IServerListener first, IServerListener second) { if (first == null) { return second; } if (second == null) { return first; } return new ServerListenerPair(first, second); }
public DetailView(IServerListener listener, Model.Client client) { InitializeComponent(); _listener = listener; _client = client; if (_client.LogPath != null) { RichTextBoxLogs.AppendText(File.ReadAllText(Path.GetFullPath(_client.LogPath))); } _client.TextReceived += new ReceivedText(ReceivedText); }
// constructors public ClusterableServer(ServerSettings settings, ClusterId clusterId, EndPoint endPoint, IConnectionPoolFactory connectionPoolFactory, IConnectionFactory hearbeatConnectionFactory, IServerListener listener) { _settings = Ensure.IsNotNull(settings, "settings");; Ensure.IsNotNull(clusterId, "clusterId"); _endPoint = Ensure.IsNotNull(endPoint, "endPoint"); _connectionPoolFactory = Ensure.IsNotNull(connectionPoolFactory, "connectionPoolFactory"); _heartbeatConnectionFactory = Ensure.IsNotNull(hearbeatConnectionFactory, "hearbeatConnectionFactory"); _listener = listener; _serverId = new ServerId(clusterId, endPoint); _baseDescription = _currentDescription = new ServerDescription(_serverId, endPoint); _connectionPool = connectionPoolFactory.CreateConnectionPool(_serverId, endPoint); _state = new InterlockedInt32(State.Initial); }
/// <summary> /// Starts the language service with the specified TCP socket port. /// </summary> /// <param name="languageServicePort">The port number for the language service.</param> /// <param name="profilePaths">The object containing the profile paths to load for this session.</param> public void StartLanguageService(EditorServiceTransportConfig config, ProfilePaths profilePaths) { this.profilePaths = profilePaths; this.languageServiceListener = CreateServiceListener(MessageProtocolType.LanguageServer, config); this.languageServiceListener.ClientConnect += this.OnLanguageServiceClientConnect; this.languageServiceListener.Start(); this.logger.Write( LogLevel.Normal, string.Format( "Language service started, type = {0}, endpoint = {1}", config.TransportType, config.Endpoint)); }
/// <summary> /// Starts the debug service with the specified config. /// </summary> /// <param name="config">The config that contains information on the communication protocol that will be used.</param> /// <param name="profilePaths">The profiles that will be loaded in the session.</param> /// <param name="useExistingSession">Determines if we will reuse the session that we have.</param> public void StartDebugService( EditorServiceTransportConfig config, ProfilePaths profilePaths, bool useExistingSession) { this.debugServiceListener = CreateServiceListener(MessageProtocolType.DebugAdapter, config); this.debugServiceListener.ClientConnect += OnDebugServiceClientConnect; this.debugServiceListener.Start(); this.logger.Write( LogLevel.Normal, string.Format( "Debug service started, type = {0}, endpoint = {1}", config.TransportType, config.Endpoint)); }
public Connection(IPAddress ip, IServerListener server) { _server = server; try { _client = new TcpClient(); _client.Connect(ip, 8080); _stream = _client.GetStream(); _server.OnConnected(); Read(); } catch (Exception e) { _server.OnErrorReceived(e.StackTrace); } }
public void Setup() { _clusterId = new ClusterId(); _connectionPool = Substitute.For <IConnectionPool>(); _connectionPoolFactory = Substitute.For <IConnectionPoolFactory>(); _connectionPoolFactory.CreateConnectionPool(null, null) .ReturnsForAnyArgs(_connectionPool); _endPoint = new DnsEndPoint("localhost", 27017); _heartbeatConnection = new MockConnection(); _heartbeatConnectionFactory = Substitute.For <IConnectionFactory>(); _heartbeatConnectionFactory.CreateConnection(null, null) .ReturnsForAnyArgs(_heartbeatConnection); _listener = Substitute.For <IServerListener>(); _settings = new ServerSettings(heartbeatInterval: Timeout.InfiniteTimeSpan); _subject = new ClusterableServer(_settings, _clusterId, _endPoint, _connectionPoolFactory, _heartbeatConnectionFactory, _listener); }
public void SendMessageToListener(IServerListener listener) { //todo & if (jArray != null) { foreach (var jToken in jArray) { if (jToken[ServerParams.ActionType].ToString() != "move") { //Debug.Log(jToken); Debug.Log(jToken[ServerParams.ActionType].ToString()); } SendMessageToListener(listener, jToken, jToken.Value <string>(ServerParams.ActionType)); } } //else //{ // SendMessageToListener(listener, jArray, jArray[ServerParams.ActionType].ToString()); //} }
public static IServerClient CreateClient(IServerListener listeners, Protocols?proto) { IServerClient sc = null; switch (proto) { case (Protocols.Tcp): { sc = new TcpServerClient(listeners.GetClientSocket()); break; } case (Protocols.Udp): { sc = new UdpServerClient(listeners.GetClientSocket()); break; } } return(sc); }
public ConnectionServer(Int32 port, IServerListener serverListener) { IPAddress addr = GetLocalIPv4(); listener = serverListener; server = new TcpListener(addr, port); server.Start(); connectionThread = new Thread(delegate() { while (true) { lock(connectionThread) { if (!running) break; } TcpClient client = server.AcceptTcpClient(); listener.onNewTcpConnection(client); } }); }
public ServerTimeoutHandler(IServerListener listener) { _listener = listener; }
public bool RemoveServerListener(IServerListener listener) { return(serverListenerSet.Remove(listener)); }
public void SendMessageToListener(IServerListener listener, String message) { Console.WriteLine("envoie au listener : " + message); Console.WriteLine(listener.ToString()); listener.MessageForListener(message); }
public Server(IServerListener listener) { _cancellationTokenSource = new CancellationTokenSource(); _cancellationToken = _cancellationTokenSource.Token; Listener = listener; }
public SingleServerTaskPool(IServerListener <T> serverLogic, ServerTaskPoolOptions options) : this(serverLogic, serverLogic, options) { }
// constructors public ServerListenerPair(IServerListener first, IServerListener second) { _first = Ensure.IsNotNull(first, "first"); _second = Ensure.IsNotNull(second, "second"); }
public bool AddServerListener(IServerListener listener) { return(serverListenerSet.Add(listener)); }
public void Setup() { _clusterId = new ClusterId(); _connectionPool = Substitute.For<IConnectionPool>(); _connectionPoolFactory = Substitute.For<IConnectionPoolFactory>(); _connectionPoolFactory.CreateConnectionPool(null, null) .ReturnsForAnyArgs(_connectionPool); _endPoint = new DnsEndPoint("localhost", 27017); _heartbeatConnection = new MockConnection(); _heartbeatConnectionFactory = Substitute.For<IConnectionFactory>(); _heartbeatConnectionFactory.CreateConnection(null, null) .ReturnsForAnyArgs(_heartbeatConnection); _listener = Substitute.For<IServerListener>(); _settings = new ServerSettings() .WithHeartbeatInterval(Timeout.InfiniteTimeSpan); _subject = new ClusterableServer(_settings, _clusterId, _endPoint, _connectionPoolFactory, _heartbeatConnectionFactory, _listener); }
public bool RemoveServerListener(IServerListener listener) { return serverListenerSet.Remove(listener); }
public bool AddServerListener(IServerListener listener) { return serverListenerSet.Add(listener); }
public void Setup() { _clusterId = new ClusterId(); _connectionPoolFactory = Substitute.For<IConnectionPoolFactory>(); _endPoint = new DnsEndPoint("localhost", 27017); _heartbeatConnectionFactory = Substitute.For<IConnectionFactory>(); _listener = Substitute.For<IServerListener>(); _settings = new ServerSettings(); }
public ClusterBuilder AddListener(IListener listener) { var clusterListener = listener as IClusterListener; if (clusterListener != null) { _clusterListener = ClusterListenerPair.Create(_clusterListener, clusterListener); } var serverListener = listener as IServerListener; if (serverListener != null) { _serverListener = ServerListenerPair.Create(_serverListener, serverListener); } var connectionPoolListener = listener as IConnectionPoolListener; if (connectionPoolListener != null) { _connectionPoolListener = ConnectionPoolListenerPair.Create(_connectionPoolListener, connectionPoolListener); } var connectionListener = listener as IConnectionListener; if (connectionListener != null) { _connectionListener = ConnectionListenerPair.Create(_connectionListener, connectionListener); } return this; }
public ServerHandler(IServerListener listener) { _listener = listener; }
private void SendMessageToListener(IServerListener listener, JToken jToken, string action) { if (action.Equals(ServerParams.GameInfoAction)) { var map = jToken["map"] as JObject; listener.GameInfoMapReceive(map); listener.GameInfoPlayersReceive(jToken["players"]); } else { var pointServer = (jToken[ServerParams.X] != null && jToken[ServerParams.Y] != null) ? new Vector2(jToken.Value <float>(ServerParams.X), jToken.Value <float>(ServerParams.Y)) : Vector2.zero; var key = GenerateKey(pointServer); var pointClient = Convector(pointServer); var playerId = jToken.Value <string>(ServerParams.UserId); if (action.Equals(ServerParams.StoneAddedAction)) { listener.WeaponAddedReceive(key, pointClient); } else if (action.Equals(ServerParams.StoneRemovedAction)) { listener.WeaponRemovedReceive(key); } else if (action.Equals(ServerParams.PlayerMoveAction)) { listener.PlayerMoveReceive(playerId, pointClient); } else if (action.Equals(ServerParams.WeaponPickAction)) { listener.WeaponPickReceive(playerId, key); } else if (action.Equals(ServerParams.BonusAddedAction)) { listener.BonusAddedReceive(key, pointClient); } else if (action.Equals(ServerParams.BonusRemovedAction)) { listener.BonusRemovedReceive(key, pointClient); } else if (action.Equals(ServerParams.BonusPickAction)) { listener.BonusPickReceive(playerId, key); } else if (action.Equals(ServerParams.UseWeaponAction)) { //aim listener.WeaponUseReceive(playerId, pointClient); } else if (action.Equals(ServerParams.PlayerRespawnAction)) { listener.PlayerRespawnReceive(playerId, pointClient); } else if (action.Equals(ServerParams.LoginAction)) { listener.LoginReceive(playerId, jToken.Value <string>(ServerParams.UserName)); } else if (action.Equals(ServerParams.PlayerDeadAction)) { listener.PlayerDeadReceive(playerId); } else if (action.Equals(ServerParams.GameTimeAction)) { listener.GameTimeReceive(jToken.Value <float>(ServerParams.GameTimeLeft)); } else if (action.Equals(ServerParams.LogoutAction)) { listener.LogoutReceive(playerId); } else if (action.Equals(ServerParams.GameResultAction)) { listener.GameResultReceive(jToken[ServerParams.Data]); } } }
// constructors /// <summary> /// Initializes a new instance of the <see cref="ServerListenerPair"/> class. /// </summary> /// <param name="first">The first server listener.</param> /// <param name="second">The second server listener.</param> public ServerListenerPair(IServerListener first, IServerListener second) { _first = Ensure.IsNotNull(first, "first"); _second = Ensure.IsNotNull(second, "second"); }