예제 #1
0
        public override Task OnConnectedAsync()
        {
            ConnectionData connectionData = new ConnectionData();

            connectionData.ConnectionId   = Context.ConnectionId;
            connectionData.ConnectionTime = DateTime.Now;
            connectionData.PeerCode       = (int)PeersEnum.PeerOne;

            var httpContext = Context.GetHttpContext();

            connectionData.Payload = $"Local Port: {httpContext.Connection.LocalPort} \n" +
                                     $" Local IP Address: {httpContext.Connection.LocalIpAddress} \n" +
                                     $" Connection Id: { httpContext.Connection.Id} \n" +
                                     $" Project Server Name: PeerOneHub";
            ConnectionList.AddUser(connectionData);

            //share this peers' info with the connected client
            Clients.All.SendAsync("ActiveConnections", ConnectionList.GetActiveConnections());

            //share this peer's TransactionPool
            Clients.All.SendAsync("ReceiveTransactions", (int)PeersEnum.PeerOne, TransactionPool.Instance.Transactions);

            //share this peers' blockchain with the connected client
            return(Clients.All.SendAsync("ReceiveCurrentBlockchain", (int)PeersEnum.PeerOne, _blockchain.Chain));
        }
예제 #2
0
        public override Task OnConnectedAsync()
        {
            ConnectionData connectionData = new ConnectionData();

            connectionData.ConnectionId   = Context.ConnectionId;
            connectionData.ConnectionTime = DateTime.Now;
            var httpContext = Context.GetHttpContext();

            connectionData.Payload = $"Local Port: {httpContext.Connection.LocalPort} \n" +
                                     $" Local IP Address: {httpContext.Connection.LocalIpAddress} \n" +
                                     $" Connection Id: { httpContext.Connection.Id} \n" +
                                     $" Project Server Name: ChatHub";
            ConnectionList.AddUser(connectionData);

            return(Clients.All.SendAsync("ActiveConnections", ConnectionList.GetActiveConnections()));
        }