void StartServer() { started = true; OperationNetwork.isServer = true; myServer = new ServerAcceptor(); myServer.StartServer(); // This is to get the server player to connect: OperationNetwork.initialConnected = 0; // The server player doesn't necessarily have to connect first. // Demo maker: ServerPerson sP = new ServerPerson(myServer); sP.setDemo(); // Revert addID: ServerPerson.addID--; RunGame.myServerThreads.Add(sP); // PlayerListHandler does not consider demo client. // Instantly connect the demo client: sP.connected = true; }
/// <summary> /// Creates a new <see cref="Server{T}"/> using <see cref="Server.ServerConfiguration"/>. /// </summary> /// <param name="configuration">The <see cref="Server.ServerConfiguration"/>.</param> public Server(ServerConfiguration configuration) { this.ServerConfiguration = configuration ?? throw new ArgumentNullException("Configuration can't be null."); this.clients = new ConcurrentDictionary <Guid, T>(); this.acceptor = new ServerAcceptor <T>(this); this.receiver = new ServerReceiver(this); this.sender = new ServerSender(); this.bufferManager = new BufferManager(configuration.MaximumNumberOfConnections, configuration.ClientBufferSize); }
public ServerAcceptorTestsBase(int maxSimultaneousConnections = -1) : base(false) { Acceptor = new ServerAcceptor(SocketType.Stream, ProtocolType.Tcp, AcceptorPool, DelayedAcceptorPool.Factory) { ListenAddress = Addr, ListenPort = Port, MaxSimultaneousConnections = maxSimultaneousConnections }; Acceptor.Accepted += OnConnected; Acceptor.AcceptFailed += OnFailed; }
public ServerSocketSlim(IBufferManager bufferManager, int maxSimultaneousConnections, int preallocatedDataCount, int acceptorPoolSize = 100, int maxPendingConnections = 100) { this.bufferManager = bufferManager; // set up acceptor ISocketAsyncEventArgsPool acceptorPool = CreateAcceptorPool(acceptorPoolSize); serverAcceptor = new ServerAcceptor(SocketType.Stream, ProtocolType.Tcp, acceptorPool, CreateAcceptor) { MaxSimultaneousConnections = maxSimultaneousConnections, MaxPendingConnections = maxPendingConnections }; serverAcceptor.Accepted += OnServerAcceptorAccepted; serverAcceptor.AcceptFailed += OnServerAcceptorAcceptFailed; // remove data pool when no preallocation is happening if (preallocatedDataCount <= 0) { channelDataPool = null; return; } // preallocate data for channels List <PreallocatedChannelData> preallocatedChannelData = new List <PreallocatedChannelData>(); for (int i = 0; i < preallocatedDataCount; i++) { preallocatedChannelData.Add(new PreallocatedChannelData()); } // set up receivers and senders foreach (PreallocatedChannelData channelData in preallocatedChannelData) { channelData.InitReceiver(bufferManager); } foreach (PreallocatedChannelData channelData in preallocatedChannelData) { channelData.InitSender(bufferManager); } // and add them into the pool foreach (PreallocatedChannelData channelData in preallocatedChannelData) { channelDataPool.PutObject(channelData); } }
protected ServerSocket(ServerAcceptor acceptor, TcpClient tcpClient) : base(tcpClient) { this._acceptor = acceptor; }
private static void CreateAndStartServer() { ServerAcceptor s = new ServerAcceptor(); s.OpenServer(port); }
public void CreateServer(string name, int port, int maxPlayer) { Connected = true; Model.ServerModel.Servername = name; Model.ServerModel.MaxPlayer = maxPlayer; Model.ServerModel.Port = port; ServerAcceptor = new ServerAcceptor(typeof(ServerSocket)); ServerAcceptor.ServerSocketCreated += ServerSocketCreated; ServerAcceptor.OpenServer(port); View.AddInfoInfo("Created server with name \""+name+"\""); View.AddInfoInfo("Listening to port \""+port+"\""); }
public ServerSocket(GUIController controller, ServerAcceptor acceptor, TcpClient tcpClient) : base(acceptor, tcpClient) { _controller = controller; }
public bool shouldNextSendOutBeFullSendOut = false; // The first few ticks doing full sendouts are not controlled by this; this is just for high choke situations public ServerPerson(ServerAcceptor parent) { this.parent = parent; id = addID++; demoName = "TestDemo" + DateTime.UtcNow.Ticks + ".dem"; }