Пример #1
0
        private void OnProtocolConnected(IUdpProtocol protocol, string address)
        {
            IOwner owner = new Owner.Owner(address);

            _toOwner.Add(address, owner);
            CallConnected(owner);
        }
Пример #2
0
 public StickyUpdServer(IPAddress address, StickyServerConfig config, IUdpProtocol protocol, ReportService reporter, ILogger logger)
     : base(address, config.Port)
 {
     Config   = config;
     Protocol = protocol;
     Reporter = reporter;
     Logger   = logger;
 }
Пример #3
0
        private void OnProtocolDisconnected(IUdpProtocol protocol, string address)
        {
            IOwner owner;

            if (_toOwner.TryGetValue(address, out owner))
            {
                _toOwner.Remove(address);
                _toAutorized.Remove(address);
                CallDisconnected(owner);
            }
        }
Пример #4
0
 private void OnProtocolAuthorizeReceived(IUdpProtocol protocol, string address, int id, string name)
 {
     if (!_authorizing.Contains(address) || !_toAutorized.Contains(address))
     {
         IOwner owner = _toOwner[address];
         CallAuthorizeReceived(owner, name, new UdpNetworkRequestCallback(protocol, address, id));
     }
     else
     {
         protocol.Error(address, _alreadyAuthorized);
     }
 }
Пример #5
0
 private void OnProtocolRequestReceived(IUdpProtocol protocol, string address, int id, IValue message)
 {
     if (_toAutorized.Contains(address))
     {
         IOwner owner = _toOwner[address];
         CallRequestReceived(owner, message, new UdpNetworkRequestCallback(protocol, address, id));
     }
     else
     {
         protocol.Error(address, _alreadyAuthorized);
     }
 }
Пример #6
0
        /// <summary>
        /// new
        /// </summary>
        /// <param name="port"></param>
        /// <param name="messageBufferSize"></param>
        /// <param name="receiveThreads"></param>
        /// <param name="protocol"></param>
        /// <param name="service"></param>
        /// <exception cref="ArgumentOutOfRangeException"></exception>
        /// <exception cref="ArgumentNullException">protocol is null.</exception>
        /// <exception cref="ArgumentNullException">service is null.</exception>
        public UdpServer(int port, int messageBufferSize, int receiveThreads,
            IUdpProtocol protocol,
            IUdpServerHandler handler)
        {
            if (receiveThreads < 1) throw new ArgumentOutOfRangeException("receiveThreads");
            if (protocol == null) throw new ArgumentNullException("protocol");
            if (handler == null) throw new ArgumentNullException("handler");

            this._port = port;
            this._messageBufferSize = messageBufferSize;
            this._receiveThreads = receiveThreads;
            this._protocol = protocol;
            this._handler = handler;
        }
Пример #7
0
        private void OnProtocolResponseReceived(IUdpProtocol protocol, string address, int id, IValue message)
        {
            var response = message as ResponseValue;

            if (response != null)
            {
                var callback = _callbacks[id].Item1;
                _sent.Remove(_callbacks[id].Item2);
                if (response.Answer == "ack")
                {
                    callback.Ack(response.Text);
                }
                else
                {
                    callback.Fail(response.Text);
                }
            }
            else
            {
                _protocol.Error(address, _notAuthorized);
            }
        }
Пример #8
0
        /// <summary>
        /// new
        /// </summary>
        /// <param name="port"></param>
        /// <param name="messageBufferSize"></param>
        /// <param name="receiveThreads"></param>
        /// <param name="protocol"></param>
        /// <param name="service"></param>
        /// <exception cref="ArgumentOutOfRangeException"></exception>
        /// <exception cref="ArgumentNullException">protocol is null.</exception>
        /// <exception cref="ArgumentNullException">service is null.</exception>
        public UdpServer(int port, int messageBufferSize, int receiveThreads,
                         IUdpProtocol protocol,
                         IUdpServerHandler handler)
        {
            if (receiveThreads < 1)
            {
                throw new ArgumentOutOfRangeException("receiveThreads");
            }
            if (protocol == null)
            {
                throw new ArgumentNullException("protocol");
            }
            if (handler == null)
            {
                throw new ArgumentNullException("handler");
            }

            this._port = port;
            this._messageBufferSize = messageBufferSize;
            this._receiveThreads    = receiveThreads;
            this._protocol          = protocol;
            this._handler           = handler;
        }
Пример #9
0
 public ProtocolUdpNetwork(IUdpProtocol protocol, INow now, int timeout)
 {
     _protocol = protocol;
     _now      = now;
     _timeout  = timeout;
 }
Пример #10
0
 /// <summary>
 /// new
 /// </summary>
 /// <param name="port"></param>
 /// <param name="protocol"></param>
 /// <param name="service"></param>
 public UdpServer(int port, IUdpProtocol protocol,
     IUdpServerHandler handler)
     : this(port, 2048, 1, protocol, handler)
 {
 }
Пример #11
0
 /// <summary>
 /// new
 /// </summary>
 /// <param name="port"></param>
 /// <param name="protocol"></param>
 /// <param name="service"></param>
 public UdpServer(int port, IUdpProtocol protocol,
                  IUdpServerHandler handler)
     : this(port, 2048, 1, protocol, handler)
 {
 }
 public UdpNetworkRequestCallback(IUdpProtocol protocol, string peer, int id)
 {
     _protocol = protocol;
     _address  = peer;
     _id       = id;
 }