Пример #1
0
 public CampaignsController(ILoggerFactory loggerFactory, GameService games, IUserService users, ISocketService sockets)
 {
     logger       = loggerFactory.CreateLogger <CampaignsController>();
     this.users   = users;
     this.games   = games;
     this.sockets = sockets;
 }
 public DotNettyServerBootstrap(IOptions <ServerAddress> address, ISocketService service, ITransportMessageCodecFactory codecFactory, ILogger <DotNettyServerBootstrap> logger)
 {
     _logger  = logger;
     _address = address;
     _decoder = codecFactory.CreateDecoder();
     _service = service;
 }
Пример #3
0
        /// <summary>
        /// new
        /// </summary>
        /// <param name="socketService"></param>
        /// <param name="protocol"></param>
        /// <param name="socketBufferSize"></param>
        /// <param name="messageBufferSize"></param>
        /// <param name="maxMessageSize"></param>
        /// <param name="maxConnections"></param>
        /// <exception cref="ArgumentNullException">socketService is null.</exception>
        /// <exception cref="ArgumentNullException">protocol is null.</exception>
        /// <exception cref="ArgumentOutOfRangeException">maxMessageSize</exception>
        /// <exception cref="ArgumentOutOfRangeException">maxConnections</exception>
        public SocketServer(ISocketService <TCommandInfo> socketService,
                            Protocol.IProtocol <TCommandInfo> protocol,
                            int socketBufferSize,
                            int messageBufferSize,
                            int maxMessageSize,
                            int maxConnections)
            : base(socketBufferSize, messageBufferSize)
        {
            if (socketService == null)
            {
                throw new ArgumentNullException("socketService");
            }
            if (protocol == null)
            {
                throw new ArgumentNullException("protocol");
            }
            if (maxMessageSize < 1)
            {
                throw new ArgumentOutOfRangeException("maxMessageSize");
            }
            if (maxConnections < 1)
            {
                throw new ArgumentOutOfRangeException("maxConnections");
            }

            this._socketService  = socketService;
            this._protocol       = protocol;
            this._maxMessageSize = maxMessageSize;
            this._maxConnections = maxConnections;
        }
Пример #4
0
 public CharactersController(GameService games, ILoggerFactory loggerFactory, IUserService users, ISocketService sockets)
 {
     this.games   = games;
     this.users   = users;
     this.sockets = sockets;
     logger       = loggerFactory.CreateLogger <CharactersController>();
 }
Пример #5
0
 /// <summary>
 ///     群分组信息查询
 /// </summary>
 public GroupCategoryCommand(byte[] data, ISocketService service, IServerMessageSubject transponder,
                             QQUser user) :
     base(data, service, transponder, user)
 {
     _packet    = new Receive_0X0195(data, _user);
     _eventArgs = new QQEventArgs <Receive_0X0195>(_service, _user, _packet);
 }
Пример #6
0
        public MainForm(Settings settings, ISocketService socket)
        {
            Socket   = socket;
            Settings = settings;

            InitializeComponent();

            // Tray Initialization
            this.InitTray(notifyIcon1, new Dictionary <string, EventHandler>()
            {
                { "Exit", Exit },
                { "Show", Show },
                { "Go Smoke", SmokeBtn_Click }
            });

            // PopUp Initialization
            this.InitPopUp(new PopUpNotifierSettings
            {
                TitleText    = "Hey Buddy ^_^",
                Duration     = 5,
                OnCloseEvent = PopUp_Close,
                Size         = new Size(new Point(400, 200))
            });

            // Settings Initialization
            this.InitSettings(settings);

            // Socket Initialization
            this.InitSocket(GoSmoke);

            InitSettings(settings);
        }
        /// <summary>
        /// Base creator for BaseSocketConnectionHost.
        /// </summary>
        /// <param name="hostType">
        /// Host type.
        /// </param>
        /// <param name="socketService">
        /// Socket service.
        /// </param>
        /// <param name="delimiterType">
        /// Delimiter type.
        /// </param>
        /// <param name="delimiter">
        /// Delimiter byte array.
        /// </param>
        /// <param name="socketBufferSize">
        /// Socket buffer size.
        /// </param>
        /// <param name="messageBufferSize">
        /// Max message buffer size.
        /// </param>
        /// <param name="idleCheckInterval">
        /// Idle check interval timeout.
        /// </param>
        /// <param name="idleTimeOutValue">
        /// Idle connection timeout.
        /// </param>
        public BaseSocketConnectionHost(HostType hostType, ISocketService socketService, DelimiterType delimiterType, byte[] delimiter, int socketBufferSize, int messageBufferSize, int idleCheckInterval, int idleTimeOutValue)
        {
            FHostType     = hostType;
            FConnectionId = 1000;

            FSocketConnectionsSync = new ReaderWriterLock();

            FSocketConnections = new Dictionary <long, BaseSocketConnection>();
            FSocketCreators    = new List <BaseSocketConnectionCreator>();
            FSocketService     = socketService;

            FWaitCreatorsDisposing    = new ManualResetEvent(false);
            FWaitConnectionsDisposing = new ManualResetEvent(false);
            FWaitThreadsDisposing     = new ManualResetEvent(false);

            FIdleCheckInterval = idleCheckInterval;
            FIdleTimeOutValue  = idleTimeOutValue;

            if ((FIdleCheckInterval > 0) && (FIdleTimeOutValue > 0))
            {
                FIdleTimer = new Timer(new TimerCallback(CheckSocketConnections));
            }

            FDelimiter     = delimiter;
            FDelimiterType = delimiterType;

            FMessageBufferSize = messageBufferSize;
            FSocketBufferSize  = socketBufferSize;

            FActive     = false;
            FSyncActive = new Object();
        }
Пример #8
0
        public MessageHandler(ISocketService webSocketService)
        {
            this.webSocketService = webSocketService;

            this.webSocketService.OnError         += (sender, e) => OnError?.Invoke(sender, e);
            this.webSocketService.MessageReceived += ParseAndHandleMessage;
        }
Пример #9
0
        /// <summary>
        /// new
        /// </summary>
        /// <param name="port"></param>
        /// <param name="socketService"></param>
        /// <param name="protocol"></param>
        /// <param name="socketBufferSize"></param>
        /// <param name="messageBufferSize"></param>
        /// <param name="maxMessageSize"></param>
        /// <param name="maxConnections"></param>
        /// <exception cref="ArgumentNullException">socketService is null.</exception>
        /// <exception cref="ArgumentNullException">protocol is null.</exception>
        /// <exception cref="ArgumentOutOfRangeException">maxMessageSize</exception>
        /// <exception cref="ArgumentOutOfRangeException">maxConnections</exception>
        public SocketServer(int port,
                            ISocketService <TMessage> socketService,
                            Protocol.IProtocol <TMessage> protocol,
                            int socketBufferSize,
                            int messageBufferSize,
                            int maxMessageSize,
                            int maxConnections)
            : base(socketBufferSize, messageBufferSize)
        {
            if (socketService == null)
            {
                throw new ArgumentNullException("socketService");
            }
            if (protocol == null)
            {
                throw new ArgumentNullException("protocol");
            }
            if (maxMessageSize < 1)
            {
                throw new ArgumentOutOfRangeException("maxMessageSize");
            }
            if (maxConnections < 1)
            {
                throw new ArgumentOutOfRangeException("maxConnections");
            }

            this._socketService  = socketService;
            this._protocol       = protocol;
            this._maxMessageSize = maxMessageSize;
            this._maxConnections = maxConnections;

            this._listener           = new SocketListener(new IPEndPoint(IPAddress.Any, port), this);
            this._listener.Accepted += this.OnAccepted;
        }
Пример #10
0
 public MainPage()
 {
     InitializeComponent();
     DataContext   = this;
     socketService = new SocketService("http://127.0.0.1:4085");
     AttachSocketEvents(socketService);
 }
Пример #11
0
 public DefaultReceiveCommand(byte[] data, ISocketService service, IServerMessageSubject transponder,
                              QQUser user)
     : base(data, service, transponder, user)
 {
     _packet    = new ReceiveCurrency(data, _user);
     _eventArgs = new QQEventArgs <ReceiveCurrency>(_service, _user, _packet);
 }
Пример #12
0
        public BaseSocketConnectionHost(HostType hostType, CallbackThreadType callbackThreadtype, ISocketService socketService, DelimiterType delimiterType, byte[] delimiter, int socketBufferSize, int messageBufferSize, int idleCheckInterval, int idleTimeOutValue)
        {
            context = new SocketProviderContext
            {
                Active = false,
                SyncActive = new object(),
                SocketCreators = new List<BaseSocketConnectionCreator>(),
                SocketConnections = new Dictionary<long, BaseSocketConnection>(),
                BufferManager = BufferManager.CreateBufferManager(0, messageBufferSize),
                SocketService = socketService,
                IdleCheckInterval = idleCheckInterval,
                IdleTimeOutValue = idleTimeOutValue,
                CallbackThreadType = callbackThreadtype,
                DelimiterType = delimiterType,
                Delimiter = delimiter,
                DelimiterEncrypt = new byte[] { 0xFE, 0xDC, 0xBA, 0x98, 0xBA, 0xDC, 0xFE },
                MessageBufferSize = messageBufferSize,
                SocketBufferSize = socketBufferSize,
                HostType = hostType
            };

            fSocketConnectionsSync = new ReaderWriterLockSlim();
            fWaitCreatorsDisposing = new ManualResetEvent(false);
            fWaitConnectionsDisposing = new ManualResetEvent(false);
            fWaitThreadsDisposing = new ManualResetEvent(false);
        }
        public CreateAccountPageModel(ISocketService socketService, ILoginCache loginCache)
        {
            this.socketService = socketService;
            this.loginCache    = loginCache;

            credentials = LoadCredentials();
        }
Пример #14
0
 public SessionManager(IDependencyManager dependencyManager, ISocketService socketService)
 {
     m_DependencyManager = dependencyManager;
     m_SocketService     = socketService;
     m_Providers         = new List <IProvider>();
     Sessions            = new List <ISession>();
 }
Пример #15
0
 public Company GetCompany(string id)
 {
     if (socketService == null)
     {
         socketService = new SocketService();
     }
     return(socketService.GetCompany(id));
 }
Пример #16
0
 public TcpServerChannelHandlerAdapter(
     ISocketService <TMessage> service,
     Protocol.IProtocol <TMessage> protocol
     ) : base(true)
 {
     this._service  = service;
     this._protocol = protocol;
 }
 public AmpTcpServerBootstrap(
     ISocketService <AmpMessage> socketService,
     IProtocol <AmpMessage> protocol,
     ILoggerFactory loggerFactory,
     IOptions <RpcServerOptions> hostOption = null)
     : base(socketService, protocol, loggerFactory, hostOption)
 {
 }
Пример #18
0
 public Company GetCompanyFromUserId(int id)
 {
     if (socketService == null)
     {
         socketService = new SocketService();
     }
     return(socketService.GetCompanyFromUserId(id));
 }
Пример #19
0
        private void SendBroadcast()
        {
            ISocketService    socketService  = Mvx.Resolve <ISocketService>();
            IIPAddressManager addressManager = Mvx.Resolve <IIPAddressManager>();
            string            address        = addressManager.GetBroadcastAddress();

            socketService.SendBroadcast("Hello", address, 52112);
        }
Пример #20
0
 public AmpTcpServerBootstrap(
     ISocketService <AmpMessage> socketService,
     IChannelHandlerPipeline handlerPipeline,
     ILoggerFactory loggerFactory,
     IOptions <RpcServerOptions> hostOption = null)
     : base(socketService, handlerPipeline, loggerFactory, hostOption)
 {
 }
Пример #21
0
 public void DeleteCompanyWish(int id)
 {
     if (socketService == null)
     {
         socketService = new SocketService();
     }
     socketService.DeleteCompanyWish(id);
 }
Пример #22
0
 protected DispatchPacketToCommand(byte[] data, ISocketService service, IServerMessageSubject transponder,
                                   QQUser user)
 {
     _data        = data;
     _service     = service;
     _transponder = transponder;
     _user        = user;
 }
Пример #23
0
        public SocketServer(int port, ISocketService service)
        {
            IPHostEntry ipHostInfo = Dns.GetHostEntry(Dns.GetHostName());

            ipAddress    = ipHostInfo.AddressList[0];
            this.service = service;
            this.port    = port;
            serverSocket = new TcpListener(IPAddress.Any, port);
        }
Пример #24
0
 public Company UpdateCompany(Company company)
 {
     if (socketService == null)
     {
         socketService = new SocketService();
     }
     socketService.UpdateCompany(company);
     return(company);
 }
 public OnkyoApi(
     ISocketService socketService,
     IDeviceDiscoveryService deviceDiscoveryService,
     IPacketService packetService
     )
 {
     _socketService          = socketService;
     _deviceDiscoveryService = deviceDiscoveryService;
     _packetService          = packetService;
 }
Пример #26
0
        public string CreateCompany(Company newCompany)
        {
            if (socketService == null)
            {
                socketService = new SocketService();
            }
            string id = socketService.AddCompany(newCompany);

            return(id);
        }
Пример #27
0
        public string CreateUser(User newUser)
        {
            if (socketService == null)
            {
                socketService = new SocketService();
            }
            string id = socketService.AddUser(newUser);

            return(id);
        }
Пример #28
0
        protected override void OnStop()
        {
            if (m_SocketService == null)
            {
                return;
            }

            Console.WriteLine("Shutting down server...");
            m_SocketService?.Dispose();
            m_SocketService = null;
            Console.WriteLine("Server shutdown.");
        }
Пример #29
0
        public MainPageViewModel()
        {
            Title = "Scan";

            _socketService                    = DependencyService.Get <ISocketService>();
            _socketService.ErrorEvent        += OnErrorEvent;
            _socketService.InfoEvent         += OnInfoEvent;
            _socketService.InChannelStarted  += OnInChannelStarted;
            _socketService.OutChannelStarted += OnOutChannelStarted;
            MessageEntryStarted              += OnMessageEntryStarted;

            SetupButtonCommands();
        }
Пример #30
0
 public MyBenchmarks()
 {
     _config = new ServerConfig
     {
         BufferSize = 10240,
         Backlog    = 240,
         IpAddress  = "127.0.0.1",
         Port       = 8787,
         Retry      = 3
     };
     _tcpService = new TcpService(_config);
     _client     = new ClientSocket();
 }
Пример #31
0
        public TcpServerBootstrap(
            ISocketService <TMessage> socketService,
            IChannelHandlerPipeline handlerPipeline,
            ILoggerFactory loggerFactory,
            IOptions <TcpHostOption> hostOption = null
            )
        {
            Preconditions.CheckNotNull(handlerPipeline, nameof(handlerPipeline));
            Preconditions.CheckNotNull(socketService, nameof(socketService));

            _options         = hostOption?.Value ?? new TcpHostOption();
            _socketService   = socketService;
            _handlerPipeline = handlerPipeline;
            _logger          = loggerFactory.CreateLogger(GetType());
        }
Пример #32
0
 public ServerSocket()
 {
     _innerSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
     _newClientSocketSignal = new ManualResetEvent(false);
     _socketService = new DefaultSocketService();
 }
Пример #33
0
 public BaseSocketConnectionHost(HostType hostType, ISocketService socketService, DelimiterType delimiterType, byte[] delimiter)
     : this(hostType, CallbackThreadType.ctWorkerThread, socketService, delimiterType, delimiter, 1024, 1024, 1000, 1000)
 {
 }
Пример #34
0
 public SocketClient(CallbackThreadType callbackThreadType, ISocketService socketService)
     : base(HostType.htClient, callbackThreadType, socketService, DelimiterType.dtNone, null, 2048, 2048, 0, 0)
 {
     //-----
 }
Пример #35
0
 public SocketClient(CallbackThreadType callbackThreadType, ISocketService socketService, DelimiterType delimiterType, byte[] delimiter)
     : base(HostType.htClient, callbackThreadType, socketService, delimiterType, delimiter, 2048, 2048, 0, 0)
 {
     //-----
 }
Пример #36
0
 public BaseSocketConnectionHost(HostType hostType, ISocketService socketService, DelimiterType delimiterType, byte[] delimiter, int idleCheckInterval, int idleTimeOutValue)
     : this(hostType, CallbackThreadType.ctWorkerThread, socketService, delimiterType, delimiter, 1024, 1024, idleCheckInterval, idleTimeOutValue)
 {
 }
Пример #37
0
 public ClientSocket()
 {
     _innerSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
     _socketService = new DefaultSocketService();
 }
Пример #38
0
 public SocketServer(CallbackThreadType callbackThreadType, ISocketService socketService, DelimiterType delimiterType, byte[] delimiter, int socketBufferSize, int messageBufferSize, int idleCheckInterval, int idleTimeOutValue)
     : base(HostType.htServer, callbackThreadType, socketService, delimiterType, delimiter, socketBufferSize, messageBufferSize, idleCheckInterval, idleTimeOutValue)
 {
     //-----
 }
        protected override void Free(bool canAccessFinalizable)
        {

            if (FIdleTimer != null)
            {
                FIdleTimer.Dispose();
                FIdleTimer = null;
            }

            if (FWaitCreatorsDisposing != null)
            {
                FWaitCreatorsDisposing.Set();
                FWaitCreatorsDisposing.Close();
                FWaitCreatorsDisposing = null;
            }

            if (FWaitConnectionsDisposing != null)
            {
                FWaitConnectionsDisposing.Set();
                FWaitConnectionsDisposing.Close();
                FWaitConnectionsDisposing = null;
            }

            if (FWaitThreadsDisposing != null)
            {
                FWaitThreadsDisposing.Set();
                FWaitThreadsDisposing.Close();
                FWaitThreadsDisposing = null;
            }

            if (FSocketConnections != null)
            {
                FSocketConnections.Clear();
                FSocketConnections = null;
            }

            if (FSocketCreators != null)
            {
                FSocketCreators.Clear();
                FSocketCreators = null;
            }

            FSocketConnectionsSync = null;
            FSocketService = null;
            FDelimiter = null;

            base.Free(canAccessFinalizable);

        }
        /// <summary>
        /// Base creator for BaseSocketConnectionHost.
        /// </summary>
        /// <param name="hostType">
        /// Host type.
        /// </param>
        /// <param name="socketService">
        /// Socket service.
        /// </param>
        /// <param name="delimiterType">
        /// Delimiter type.
        /// </param>
        /// <param name="delimiter">
        /// Delimiter byte array.
        /// </param>
        /// <param name="socketBufferSize">
        /// Socket buffer size.
        /// </param>
        /// <param name="messageBufferSize">
        /// Max message buffer size.
        /// </param>
        /// <param name="idleCheckInterval">
        /// Idle check interval timeout.
        /// </param>
        /// <param name="idleTimeOutValue">
        /// Idle connection timeout.
        /// </param>
        public BaseSocketConnectionHost(HostType hostType, ISocketService socketService, DelimiterType delimiterType, byte[] delimiter, int socketBufferSize, int messageBufferSize, int idleCheckInterval, int idleTimeOutValue)
        {

            FHostType = hostType;
            FConnectionId = 1000;

            FSocketConnectionsSync = new ReaderWriterLock();

            FSocketConnections = new Dictionary<long, BaseSocketConnection>();
            FSocketCreators = new List<BaseSocketConnectionCreator>();
            FSocketService = socketService;

            FWaitCreatorsDisposing = new ManualResetEvent(false);
            FWaitConnectionsDisposing = new ManualResetEvent(false);
            FWaitThreadsDisposing = new ManualResetEvent(false);

            FIdleCheckInterval = idleCheckInterval;
            FIdleTimeOutValue = idleTimeOutValue;

            if ( (FIdleCheckInterval > 0) && (FIdleTimeOutValue > 0) )
            {
                FIdleTimer = new Timer(new TimerCallback(CheckSocketConnections));
            }

            FDelimiter = delimiter;
            FDelimiterType = delimiterType;

            FMessageBufferSize = messageBufferSize;
            FSocketBufferSize = socketBufferSize;

            FActive = false;
            FSyncActive = new Object();

        }
Пример #41
0
 public SocketServer(ISocketService socketService)
     : base(HostType.htServer, socketService, DelimiterType.dtNone, null, 4096, 8192, 0, 0)
 {
     //-----
 }
Пример #42
0
 public SocketClient(ISocketService socketService)
     : base(HostType.htClient, socketService, DelimiterType.dtNone, null, 2048, 8192, 0, 0)
 {
     //-----
 }
Пример #43
0
 public SocketClient(ISocketService socketService, DelimiterType delimiterType, byte[] delimiter)
     : base(HostType.htClient, socketService, delimiterType, delimiter, 2048, 8192, 0, 0)
 {
     //-----
 }
Пример #44
0
 public SocketClient(ISocketService socketService, DelimiterType delimiterType, byte[] delimiter, int socketBufferSize, int messageBufferSize)
     : base(HostType.htClient, socketService, delimiterType, delimiter, socketBufferSize, messageBufferSize, 0, 0)
 {
     //-----
 }
Пример #45
0
 public SocketClient(ISocketService socketService, DelimiterType delimiterType, byte[] delimiter, int socketBufferSize, int messageBufferSize, int idleCheckInterval, int idleTimeOutValue)
     : base(HostType.htClient, socketService, delimiterType, delimiter, socketBufferSize, messageBufferSize, idleCheckInterval, idleTimeOutValue)
 {
     //-----
 }
Пример #46
0
 public SocketServer(CallbackThreadType callbackThreadType, ISocketService socketService, DelimiterType delimiterType, byte[] delimiter, int socketBufferSize, int messageBufferSize)
     : base(HostType.htServer, callbackThreadType, socketService, delimiterType, delimiter, socketBufferSize, messageBufferSize, 0, 0)
 {
     //-----
 }
Пример #47
0
 public SocketServer(ISocketService socketService, DelimiterType delimiterType, byte[] delimiter)
     : base(HostType.htServer, socketService, delimiterType, delimiter, 4096, 8192, 0, 0)
 {
     //-----
 }