public async Task StartAsync(EndPoint endPoint)
        {
            var config = new TcpSocketSaeaServerConfiguration();
            _server = new TcpSocketSaeaServer((IPEndPoint)endPoint, new SimpleMessageDispatcher((session, message) =>
            {
                var sender = new SimpleServerMessageSender(_transportMessageEncoder, session, _logger);
                OnReceived(sender, message);
            }, _transportMessageDecoder, _logger), config);
            _server.Listen();

#if NET45 || NET451
            await Task.FromResult(1);
#else
            await Task.CompletedTask;
#endif
        }
        public async Task StartAsync(EndPoint endPoint)
        {
            var config = new TcpSocketSaeaServerConfiguration();

            _server = new TcpSocketSaeaServer((IPEndPoint)endPoint, new SimpleMessageDispatcher((session, message) =>
            {
                var sender = new SimpleServerMessageSender(_transportMessageEncoder, session, _logger);
                OnReceived(sender, message);
            }, _transportMessageDecoder, _logger), config);
            _server.Listen();

#if NET
            await Task.FromResult(1);
#else
            await Task.CompletedTask;
#endif
        }
Example #3
0
        public async Task StartAsync(EndPoint endPoint)
        {
            _server = new TcpSocketSaeaServer((IPEndPoint)endPoint, async (session, data, offset, count) =>
            {
                if (_logger.IsEnabled(LogLevel.Information))
                    _logger.LogInformation("接收到数据包。");
                var message = _transportMessageDecoder.Decode(data.Skip(offset).Take(count).ToArray());
                if (_logger.IsEnabled(LogLevel.Information))
                    _logger.LogInformation("接收到消息:" + message.Id);
                var sender = new SimpleServerMessageSender(_transportMessageEncoder, session, _logger);
                await OnReceived(sender, message);
            });
            _server.Listen();

#if NET
            await Task.FromResult(1);
#else
            await Task.CompletedTask;
#endif
        }
Example #4
0
        public async Task StartAsync(EndPoint endPoint)
        {
            _server = new TcpSocketSaeaServer((IPEndPoint)endPoint, async(session, data, offset, count) =>
            {
                if (_logger.IsEnabled(LogLevel.Information))
                {
                    _logger.LogInformation("接收到数据包。");
                }
                var message = _transportMessageDecoder.Decode(data.Skip(offset).Take(count).ToArray());
                if (_logger.IsEnabled(LogLevel.Information))
                {
                    _logger.LogInformation("接收到消息:" + message.Id);
                }
                var sender = new SimpleServerMessageSender(_transportMessageEncoder, session, _logger);
                await OnReceived(sender, message);
            });
            _server.Listen();

#if NET
            await Task.FromResult(1);
#else
            await Task.CompletedTask;
#endif
        }