コード例 #1
0
        public override string ToCSV()
        {
            try
            {
                string serverEndPointValue = (ServerEndPoint != null) ? ServerEndPoint.ToString() : null;
                string remoteEndPointValue = (RemoteEndPoint != null) ? RemoteEndPoint.ToString() : null;
                string dstEndPointValue    = (DestinationEndPoint != null) ? DestinationEndPoint.ToString() : null;

                string csvEvent =
                    SERIALISATION_PREFIX + "|" +
                    SessionID + "|" +
                    MonitorServerID + "|" +
                    ServerType + "|" +
                    EventType + "|" +
                    Created.ToString(SERIALISATION_DATETIME_FORMAT) + "|" +
                    serverEndPointValue + "|" +
                    remoteEndPointValue + "|" +
                    dstEndPointValue + "|" +
                    Username + "|" +
                    ProcessID + "|" +
                    Message + END_MESSAGE_DELIMITER;

                return(csvEvent);
            }
            catch (Exception excp)
            {
                Logger.Logger.Error("Exception SIPMonitorConsoleEvent ToCSV. ->" + excp.Message);
                return(null);
            }
        }
コード例 #2
0
        public override ConnectionInfo GetConnectionInfo()
        {
            ConnectionStatus status = ConnectionStatus.Connected;

            if (IsStopped)
            {
                status = HasError ? ConnectionStatus.Error : ConnectionStatus.Idle;
            }
            string user_agent = "";

            if (request.Headers.ContainsKey("USER-AGENT"))
            {
                user_agent = request.Headers["USER-AGENT"];
            }
            return(new ConnectionInfoBuilder()
            {
                ProtocolName = "HTTP Direct",
                Type = ConnectionType.Direct,
                Status = status,
                RemoteName = RemoteEndPoint.ToString(),
                RemoteEndPoint = (IPEndPoint)RemoteEndPoint,
                RemoteHostStatus = IsLocal ? RemoteHostStatus.Local : RemoteHostStatus.None,
                ContentPosition = lastPacket != null ? lastPacket.Position : 0,
                RecvRate = Connection.ReadRate,
                SendRate = Connection.WriteRate,
                AgentName = user_agent,
            }.Build());
        }
コード例 #3
0
        public override string ToCSV()
        {
            try
            {
                int    machineEventTypeId = (int)MachineEventType;
                string remoteSocket       = (RemoteEndPoint != null) ? RemoteEndPoint.ToString() : null;
                string resourceURIStr     = (ResourceURI != null) ? ResourceURI.ToString() : null;

                string csvEvent =
                    SERIALISATION_PREFIX + "|" +
                    SessionID + "|" +
                    MonitorServerID + "|" +
                    machineEventTypeId + "|" +
                    Created.ToString(SERIALISATION_DATETIME_FORMAT) + "|" +
                    Username + "|" +
                    remoteSocket + "|" +
                    Message + "|" +
                    ResourceID + "|" +
                    resourceURIStr
                    + END_MESSAGE_DELIMITER;

                return(csvEvent);
            }
            catch (Exception excp)
            {
                logger.Error("Exception SIPMonitorMachineEvent ToCSV. " + excp.Message);
                return(null);
            }
        }
コード例 #4
0
        public override ConnectionInfo GetConnectionInfo()
        {
            ConnectionStatus status = ConnectionStatus.Connected;

            if (IsStopped)
            {
                status = HasError ? ConnectionStatus.Error : ConnectionStatus.Idle;
            }
            string user_agent = "";

            if (request.Headers.ContainsKey("USER-AGENT"))
            {
                user_agent = request.Headers["USER-AGENT"];
            }
            return(new ConnectionInfo(
                       "HTTP Direct",
                       ConnectionType.Direct,
                       status,
                       RemoteEndPoint.ToString(),
                       (IPEndPoint)RemoteEndPoint,
                       IsLocal ? RemoteHostStatus.Local : RemoteHostStatus.None,
                       sentPacket != null ? sentPacket.Position : 0,
                       RecvRate,
                       SendRate,
                       null,
                       null,
                       user_agent));
        }
コード例 #5
0
        /// <summary>
        /// Use this function in order to connect and authenticate.
        /// </summary>
        /// <param name="key">Your API key.</param>
        public async Task Connect(string key, bool useTls, Action <BaseMessage> received)
        {
            this.Client = new ClientWebSocket();
            Uri url;

            if (useTls)
            {
                url = new Uri($"wss://{RemoteEndPoint.ToString()}");
            }
            else
            {
                url = new Uri($"ws://{RemoteEndPoint.ToString()}");
            }

            await Client.ConnectAsync(url, CancellationToken.None).ConfigureAwait(false);

            this.Transport = new BlackTeaTransport(Client, key, received);
            if (await Transport.Authenticate().ConfigureAwait(false))
            {
                Connected = true;
            }
            else
            {
                throw new InvalidCredentialException("Login rejected.");
            }
        }
コード例 #6
0
        private void OnConstructing(IPEndPoint remote, IPEndPoint local)
        {
            _remote = remote;
            _local  = local;
            created = true;
            try
            {
                if (remote == null)
                {
                    throw new ArgumentNullException(nameof(remote));
                }

                AddressFamily family = remote.AddressFamily;

                if (remote.Port.NotIn(IPEndPoint.MinPort, IPEndPoint.MaxPort))
                {
                    throw new ArgumentOutOfRangeException(nameof(remote.Port), $"The {nameof(remote.Port)} must between {IPEndPoint.MinPort} to {IPEndPoint.MaxPort}.");
                }

                if (remote.Port < 1)
                {
                    throw new ArgumentOutOfRangeException(nameof(remote.Port));
                }

                switch (family)
                {
                case AddressFamily.InterNetwork:
                case AddressFamily.InterNetworkV6:
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(family), $"The AddressFamily only support AddressFamily.InterNetwork and AddressFamily.InterNetworkV6.");
                }

                if (local != null && local.AddressFamily != family)
                {
                    throw new ArgumentException($"The {nameof(local)} and {nameof(family)} not match.");
                }

                Instance = new Socket(family, SocketType.Stream, ProtocolType.Tcp);
                if (local != null && local.Port > 0)
                {
                    Instance.Bind(local);
                }

                this.RemoteEndPoint = remote;
                if (local?.Port > 0)
                {
                    this.LocalEndPoint = local;
                }

                this.Key  = RemoteEndPoint.ToString();
                this.Name = this.Name ?? this.Key;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #7
0
ファイル: RRPCSession.cs プロジェクト: 2821840032/FRPCServer
        /// <summary>
        /// 连接断开
        /// </summary>
        /// <param name="reason"></param>
        protected override void OnSessionClosed(CloseReason reason)
        {
            this.Log($"远程连接断开 IP-Prot:{RemoteEndPoint.ToString()}、ID:{SessionID}");
            //释放所有的任务
            RemoteCallQueue.ErrorEmpty("远程对象被关闭 原因:" + reason);

            base.OnSessionClosed(reason);
        }
コード例 #8
0
        protected override void OnConnect(IOArgs args)
        {
            Console.WriteLine($"Connected to { RemoteEndPoint.ToString()} ");

            //Sending string or Memory<byte> will automaticly create IOArgs with pooled buffer.
            //Send($"HELLO FROM { LocalEndPoint }");

            args.SetBuffer($"HELLO FROM { LocalEndPoint }"); //Copy string to our IOArg's buffer.
            SendArgs(args);
        }
コード例 #9
0
ファイル: ClientSocket.cs プロジェクト: xTVaser/JakX-Server
 public override string ToString()
 {
     if (ClientObject?.ClientAccount != null)
     {
         return(ClientObject.ClientAccount.AccountName);
     }
     else
     {
         return(RemoteEndPoint?.ToString());
     }
 }
コード例 #10
0
 public void Send()
 {
     if (ParentServer == null)
     {
         return;
     }
     if (mustSend)//only send a packet if we have data to send
     {
         lock (this)
         {
             IBitStream stream = BitStream.Create();                                //create new bitstream
             stream.WriteBasicHeader(15, ConnectionId);                             //write packet type and client id
             stream.WriteExtendedHeader(ServerPacketId, ClientPacketId, (uint)v54); //write packet identifiers
             ServerPacketId++;
             var position = stream.GetPosition();
             stream.SkipBits(16);
             stream.WriteBits(0, 1);//playeractionmanager
             if (GameEvents.Count > 0)
             {
                 stream.WriteBits(1, 1);
                 lock (GameEvents)
                 {
                     List <IGameEvent> events = new List <IGameEvent>();
                     for (int i = 4; i > 0; i--)
                     {
                         IGameEvent gameEvent;
                         if (!GameEvents.TryDequeue(out gameEvent))
                         {
                             break;
                         }
                         events.Add(gameEvent);
                     }
                     GameEventManager.Transmit(stream, events);
                 }
             }
             else
             {
                 stream.WriteBits(0, 1);
             }
             stream.WriteBits(0, 1);//ghostmanager
             var lastPosition = stream.GetPosition();
             stream.SetPosition(position);
             stream.WriteBits(((uint)(lastPosition - 72) / 8), 16);
             stream.SetPosition(lastPosition);
             ParentServer.Send(stream.GetRawBuffer(), RemoteEndPoint);
             Console.WriteLine("[NetworkingClient - " + RemoteEndPoint.ToString() + "] sent packet type " + Convert.ToString(PacketType.Data));
             mustSend = false;
         }
     }
     else
     {
         SendPingRequest();
     }
 }
コード例 #11
0
 public void Send(string hex)
 {
     lock (this)
     {
         IBitStream stream = new BitStream(DevelopmentHelper.ParseHexString(hex)); //create new bitstream
         stream.WriteBasicHeader(15, ConnectionId);                                //write packet type and client id
         stream.WriteExtendedHeader(ServerPacketId, ClientPacketId, (uint)v54);    //write packet identifiers
         ServerPacketId++;
         ParentServer.Send(stream.GetRawBuffer(), RemoteEndPoint);
         Console.WriteLine("[NetworkingClient - " + RemoteEndPoint.ToString() + "] sent packet type " + Convert.ToString(PacketType.Data));
     }
 }
コード例 #12
0
        public override ConnectionInfo GetConnectionInfo()
        {
            ConnectionStatus status = ConnectionStatus.Connected;

            if (IsStopped)
            {
                status = HasError ? ConnectionStatus.Error : ConnectionStatus.Idle;
            }
            var host_status = RemoteHostStatus.None;

            if (IsLocal)
            {
                host_status |= RemoteHostStatus.Local;
            }
            var relay_count  = 0;
            var direct_count = 0;

            if (Downhost != null)
            {
                if (Downhost.IsFirewalled)
                {
                    host_status |= RemoteHostStatus.Firewalled;
                }
                if (Downhost.IsRelayFull)
                {
                    host_status |= RemoteHostStatus.RelayFull;
                }
                if (Downhost.IsReceiving)
                {
                    host_status |= RemoteHostStatus.Receiving;
                }
                relay_count  = Downhost.RelayCount;
                direct_count = Downhost.DirectCount;
            }
            return(new ConnectionInfoBuilder {
                ProtocolName = "PCP Relay",
                Type = ConnectionType.Relay,
                Status = status,
                RemoteName = RemoteEndPoint.ToString(),
                RemoteEndPoint = (IPEndPoint)RemoteEndPoint,
                RemoteHostStatus = host_status,
                RemoteSessionID = Downhost?.SessionID,
                ContentPosition = lastPosition,
                RecvRate = Connection.ReadRate,
                SendRate = Connection.WriteRate,
                LocalRelays = relay_count,
                LocalDirects = direct_count,
                AgentName = this.UserAgent ?? "",
            }.Build());
        }
コード例 #13
0
 public override ConnectionInfo GetConnectionInfo()
 {
     return(new ConnectionInfoBuilder {
         ProtocolName = "No Protocol Matched",
         Type = ConnectionType.Metadata,
         Status = ConnectionStatus.Connected,
         RemoteName = RemoteEndPoint.ToString(),
         RemoteEndPoint = (IPEndPoint)RemoteEndPoint,
         RemoteHostStatus = IsLocal ? RemoteHostStatus.Local : RemoteHostStatus.None,
         RecvRate = Connection.ReadRate,
         SendRate = Connection.WriteRate,
         AgentName = request.Headers["USER-AGENT"],
     }.Build());
 }
コード例 #14
0
        /// <summary>
        /// Returns a string containing suitable information about this connection
        /// </summary>
        /// <returns>A string containing suitable information about this connection</returns>
        public override string ToString()
        {
            //Add a useful connection state identifier
            string connectionStateIdentifier;

            switch (ConnectionState)
            {
            case ConnectionState.Undefined:
                connectionStateIdentifier = "U";
                break;

            case ConnectionState.Establishing:
                connectionStateIdentifier = "I";
                break;

            case ConnectionState.Established:
                connectionStateIdentifier = "E";
                break;

            case ConnectionState.Shutdown:
                connectionStateIdentifier = "S";
                break;

            default:
                throw new Exception("Unexpected connection state.");
            }

            string returnString = "[" + ConnectionType.ToString() + "-" + (ApplicationLayerProtocol == ApplicationLayerProtocolStatus.Enabled ? "E" : "D") + "-" + connectionStateIdentifier + "] ";

            if (RemoteEndPoint != null && LocalEndPoint != null)
            {
                returnString += LocalEndPoint.ToString() + " -> " + RemoteEndPoint.ToString();
            }
            else if (RemoteEndPoint != null)
            {
                returnString += "Local -> " + RemoteEndPoint.ToString();
            }
            else if (LocalEndPoint != null)
            {
                returnString += LocalEndPoint.ToString() + " " + (IsConnectable ? "Connectable" : "NotConnectable");
            }

            if (NetworkIdentifier != ShortGuid.Empty)
            {
                returnString += " (" + NetworkIdentifier + ")";
            }

            return(returnString.Trim());
        }
 /// <summary>
 /// Returns a <see cref="System.String" /> that represents this instance.
 /// </summary>
 /// <returns>
 /// A <see cref="System.String" /> that represents this instance.
 /// </returns>
 public override string ToString()
 {
     return(String.Format(
                "LocalEndPoint: {1}{0}" +
                "RemoteEndPoint: {2}{0}" +
                "State: {3}{0}" +
                "Pid:{4}{0}" +
                "Process: {5}",
                Environment.NewLine,
                LocalEndPoint.ToString(),
                RemoteEndPoint.ToString(),
                State,
                ProcessId,
                Process.ProcessName));
 }
コード例 #16
0
        public override ConnectionInfo GetConnectionInfo()
        {
            ConnectionStatus status = ConnectionStatus.Connected;

            if (IsStopped)
            {
                status = HasError ? ConnectionStatus.Error : ConnectionStatus.Idle;
            }
            var host_status = RemoteHostStatus.None;

            if (IsLocal)
            {
                host_status |= RemoteHostStatus.Local;
            }
            var relay_count  = 0;
            var direct_count = 0;

            if (Downhost != null)
            {
                if (Downhost.IsFirewalled)
                {
                    host_status |= RemoteHostStatus.Firewalled;
                }
                if (Downhost.IsRelayFull)
                {
                    host_status |= RemoteHostStatus.RelayFull;
                }
                if (Downhost.IsReceiving)
                {
                    host_status |= RemoteHostStatus.Receiving;
                }
                relay_count  = Downhost.RelayCount;
                direct_count = Downhost.DirectCount;
            }
            return(new ConnectionInfo(
                       "PCP Relay",
                       ConnectionType.Relay,
                       status,
                       RemoteEndPoint.ToString(),
                       (IPEndPoint)RemoteEndPoint,
                       host_status,
                       lastContent != null ? lastContent.Position : 0,
                       RecvRate,
                       SendRate,
                       relay_count,
                       direct_count,
                       relayRequest.UserAgent));
        }
コード例 #17
0
        internal TcpConnection(Socket socket)
        {
            if (socket.LocalEndPoint == null && socket.RemoteEndPoint == null)
            {
                throw new ArgumentException("This socket is not connected.");
            }

            this.Instance       = socket;
            this.LocalEndPoint  = socket.LocalEndPoint.As();
            this.RemoteEndPoint = socket.RemoteEndPoint.As();

            this.Key  = RemoteEndPoint.ToString();
            this.Name = this.Name ?? this.Key;

            connected = true;
        }
コード例 #18
0
 public override ConnectionInfo GetConnectionInfo()
 {
     return(new ConnectionInfo(
                "No Protocol Matched",
                ConnectionType.Metadata,
                ConnectionStatus.Connected,
                RemoteEndPoint.ToString(),
                (IPEndPoint)RemoteEndPoint,
                IsLocal ? RemoteHostStatus.Local : RemoteHostStatus.None,
                null,
                RecvRate,
                SendRate,
                null,
                null,
                request.Headers["USER-AGENT"]));
 }
コード例 #19
0
 public void SendPingResponse(uint token)
 {
     try
     {
         var buff   = new byte[0xffff];
         var stream = new BitStream(buff);
         stream.WriteBasicHeader((uint)PacketType.PingResponse, ConnectionId);
         stream.WriteExtendedHeader(ServerPacketId, ClientPacketId, (uint)v54);
         stream.WriteBits(0, 1);
         stream.WriteBits(token, 32);
         stream.WriteBits(0, 32);//some timestamp
         ParentServer.Send(stream.GetRawBuffer(), RemoteEndPoint);
         Console.WriteLine("[NetworkingClient - " + RemoteEndPoint.ToString() + "] sent packet type " + Convert.ToString(PacketType.PingResponse));
     }
     catch (Exception)
     {
     }
 }
コード例 #20
0
        private EpoxyConnection(
            ConnectionType connectionType,
            EpoxyTransport parentTransport,
            EpoxyListener parentListener,
            ServiceHost serviceHost,
            Socket socket,
            Logger logger,
            Metrics metrics)
        {
            Debug.Assert(parentTransport != null);
            Debug.Assert(connectionType != ConnectionType.Server || parentListener != null, "Server connections must have a listener");
            Debug.Assert(serviceHost != null);
            Debug.Assert(socket != null);

            this.connectionType = connectionType;

            this.parentTransport = parentTransport;
            this.parentListener  = parentListener;
            this.serviceHost     = serviceHost;

            netSocket = new EpoxySocket(socket, logger);

            // cache these so we can use them after the socket has been shutdown
            LocalEndPoint  = (IPEndPoint)socket.LocalEndPoint;
            RemoteEndPoint = (IPEndPoint)socket.RemoteEndPoint;

            responseMap = new ResponseMap();

            state               = State.Created;
            startTask           = new TaskCompletionSource <bool>();
            stopTask            = new TaskCompletionSource <bool>();
            shutdownTokenSource = new CancellationTokenSource();

            // start at -1 or 0 so the first conversation ID is 1 or 2.
            prevConversationId = (connectionType == ConnectionType.Client) ? -1 : 0;

            connectionMetrics.connection_id   = Guid.NewGuid().ToString();
            connectionMetrics.local_endpoint  = LocalEndPoint.ToString();
            connectionMetrics.remote_endpoint = RemoteEndPoint.ToString();

            this.logger  = logger;
            this.metrics = metrics;
        }
コード例 #21
0
        public override ConnectionInfo GetConnectionInfo()
        {
            ConnectionStatus status = ConnectionStatus.Connected;

            if (IsStopped)
            {
                status = HasError ? ConnectionStatus.Error : ConnectionStatus.Idle;
            }
            return(new ConnectionInfoBuilder {
                ProtocolName = "OWIN Host",
                Type = ConnectionType.Interface,
                Status = status,
                RemoteName = RemoteEndPoint.ToString(),
                RemoteEndPoint = (IPEndPoint)RemoteEndPoint,
                RemoteHostStatus = IsLocal ? RemoteHostStatus.Local : RemoteHostStatus.None,
                RecvRate = Connection.ReadRate,
                SendRate = Connection.WriteRate,
                AgentName = request.Headers["USER-AGENT"],
            }.Build());
        }
コード例 #22
0
        public override ConnectionInfo GetConnectionInfo()
        {
            ConnectionStatus status = ConnectionStatus.Connected;

            if (IsStopped)
            {
                status = HasError ? ConnectionStatus.Error : ConnectionStatus.Idle;
            }
            return(new ConnectionInfoBuilder {
                ProtocolName = "PCP Pong",
                Type = ConnectionType.Metadata,
                Status = status,
                RemoteName = RemoteEndPoint.ToString(),
                RemoteEndPoint = (IPEndPoint)RemoteEndPoint,
                RemoteHostStatus = IsLocal ? RemoteHostStatus.Local : RemoteHostStatus.None,
                RemoteSessionID = RemoteSessionID,
                RecvRate = Connection.ReadRate,
                SendRate = Connection.WriteRate,
            }.Build());
        }
コード例 #23
0
        public override ConnectionInfo GetConnectionInfo()
        {
            ConnectionStatus status = ConnectionStatus.Connected;

            if (IsStopped)
            {
                status = HasError ? ConnectionStatus.Error : ConnectionStatus.Idle;
            }
            return(new ConnectionInfo(
                       "PCP Pong",
                       ConnectionType.Metadata,
                       status,
                       RemoteEndPoint.ToString(),
                       (IPEndPoint)RemoteEndPoint,
                       IsLocal ? RemoteHostStatus.Local : RemoteHostStatus.None,
                       null,
                       RecvRate,
                       SendRate,
                       null,
                       null,
                       null));
        }
コード例 #24
0
ファイル: iCamListener.cs プロジェクト: pvandyk-tmt/ITS
        private void ConnectCallback(IAsyncResult ar)
        {
            try
            {
                var sender = (Socket)ar.AsyncState;
                sender.EndConnect(ar);

                Log.DebugFormat("Socket connected to {0}.", RemoteEndPoint.ToString());

                _connectDone.Set();
            }
            catch (SocketException se)
            {
                Log.Error(string.Format("Socket failed to connect to {0}.", RemoteEndPoint), se);
                _connectDone.Set();
            }
            catch (Exception ex)
            {
                Log.Error(string.Format("Socket failed to connect to {0}.", RemoteEndPoint), ex);
                _connectDone.Set();
            }
        }
コード例 #25
0
        private void HubConnectionConnectionStatusChanged(object sender, ConnectionStatusEventArgs e)
        {
            switch (e.Status)
            {
            case ConnectionStatus.Connecting:
                _lastChatMessage = null;
                break;

            case ConnectionStatus.Connected:
                RemoteAddressString = RemoteEndPoint.ToString();
                break;

            case ConnectionStatus.Disconnected:
                _prevMessage = default(MyINFOMessage);
                if (!string.IsNullOrEmpty(_lastChatMessage))
                {
                    Logger.Info("Last hub chat message: {0}", _lastChatMessage);
                }
                Active = false;
                break;
            }
        }
コード例 #26
0
            public override ConnectionInfo GetConnectionInfo()
            {
                ConnectionStatus status = ConnectionStatus.Connected;

                if (IsStopped)
                {
                    status = HasError ? ConnectionStatus.Error : ConnectionStatus.Idle;
                }
                return(new ConnectionInfo(
                           "HTML Host",
                           ConnectionType.Interface,
                           status,
                           RemoteEndPoint.ToString(),
                           (IPEndPoint)RemoteEndPoint,
                           IsLocal ? RemoteHostStatus.Local : RemoteHostStatus.None,
                           null,
                           RecvRate,
                           SendRate,
                           null,
                           null,
                           request.Headers["USER-AGENT"]));
            }
コード例 #27
0
        public async Task SuccessAsync(string sessionid)
        {
            await InstanceNotifier.Instance.AuthenticatedAsync(AccountInfo.AccountName, sessionid, RemoteEndPoint).ConfigureAwait(false);

            await EventLogger.Instance.SuccessEventAsync(RemoteEndPoint, AccountInfo.AccountName).ConfigureAwait(false);

            using (AccountsDatabaseContext context = new AccountsDatabaseContext()) {
                context.Accounts.Attach(AccountInfo);

                AccountInfo.SessionId = sessionid;
                AccountInfo.EndPoint  = RemoteEndPoint.ToString();

                await context.SaveChangesAsync().ConfigureAwait(false);
            }

            await SendAsync(new SuccessMessage()
            {
                SessionId = sessionid,
            }).ConfigureAwait(false);

            await DisconnectAsync().ConfigureAwait(false);
        }
コード例 #28
0
ファイル: ClientConnection.cs プロジェクト: Amitkapadi/WISP
        private void OnConnectionAttemptConcluded(SocketAsyncEventArgs args)
        {
            args.Completed        -= new EventHandler <SocketAsyncEventArgs>(OnConnectEvent_Completed);
            m_ConnectionInProgress = false;

            try
            {
                if (args.SocketError != SocketError.Success)
                {
                    FireConnectedEvent(false, args.SocketError.ToString());
                    return;
                }
            }
            catch (Exception conExc)
            {
                FireConnectedEvent(false, "Unable to connect to server: " + conExc.Message);
                return;
            }

            FireConnectedEvent(true, "Endpoint " + RemoteEndPoint.ToString());

            try
            {
                // send serviceId request
                Log.LogMsg("Sending service ID " + ServiceID.ToString());
                Send(BitConverter.GetBytes(ServiceID), PacketFlags.IsCritical);

                if (!Transit.ListenForDataOnSocket())
                {
                    // ListenForDataOnSocket calls all appropriate kill events
                    KillConnection("Failed to listen on socket.");
                    return;
                }
            }
            catch (Exception con2Exc)
            {
                KillConnection(con2Exc.Message);
            }
        }
コード例 #29
0
ファイル: EpoxyConnection.cs プロジェクト: xrcdev/bond
        private EpoxyConnection(
            ConnectionType connectionType,
            EpoxyTransport parentTransport,
            EpoxyListener parentListener,
            ServiceHost serviceHost,
            EpoxyNetworkStream networkStream,
            Logger logger,
            Metrics metrics)
        {
            Debug.Assert(parentTransport != null);
            Debug.Assert(connectionType != ConnectionType.Server || parentListener != null, "Server connections must have a listener");
            Debug.Assert(serviceHost != null);
            Debug.Assert(networkStream != null);

            this.connectionType = connectionType;

            this.parentTransport = parentTransport;
            this.parentListener  = parentListener;
            this.serviceHost     = serviceHost;

            this.networkStream = networkStream;

            responseMap = new ResponseMap();

            state               = State.Created;
            startTask           = new TaskCompletionSource <bool>();
            stopTask            = new TaskCompletionSource <bool>();
            shutdownTokenSource = new CancellationTokenSource();

            // start at -1 or 0 so the first conversation ID is 1 or 2.
            prevConversationId = (connectionType == ConnectionType.Client) ? -1 : 0;

            ConnectionMetrics.local_endpoint  = LocalEndPoint.ToString();
            ConnectionMetrics.remote_endpoint = RemoteEndPoint.ToString();

            this.logger  = logger;
            this.metrics = metrics;
        }
コード例 #30
0
ファイル: TcpConnection.cs プロジェクト: tone81/EventStore
 public override string ToString()
 {
     return(RemoteEndPoint.ToString());
 }