public ChatClientNetChannel(IActorSystem<IRoomActor> rooms, ICallbacksGatewayNode callbacksNode, INetNode node,  
     ITransportChannel transportChannel, IMessageSerializer serializer, ICoreEvents logger, INetNodeConfig config, IBufferPool bufferPool) 
     : base(node, transportChannel, serializer, logger, config, bufferPool)
 {
     _rooms = rooms;
     _callbacksNode = callbacksNode;
 }
Example #2
0
 public void ActorActivated(INetNode node, ActorKey actorKey)
 {
     if (_logger.IsEnabled(LogEventLevel.Information))
     {
         _logger.Information("actor:{@actorKey} is activated on node:{@node}", actorKey, node);
     }
 }
Example #3
0
 public void ConnectionHasTimedOut(INetNode node, IPEndPoint address)
 {
     if (_logger.IsEnabled(LogEventLevel.Warning))
     {
         _logger.Warning("NetNode {@node} has failed to connect to {@address} within alloted time", node, address);
     }
 }
Example #4
0
 public void NetChannelRequestFailed(INetNode node, NetChannel channel, ErrorMessage error, Guid requestId, int durationMs)
 {
     if (_logger.IsEnabled(LogEventLevel.Warning))
     {
         _logger.Warning("NetNode {@node} NetChannel {@channel} sent request failed with {@error} for {requestId} in {durationMs} ms", node, channel, error, requestId, durationMs);
     }
 }
Example #5
0
 public void NetChannelDisconnected(INetNode node, INetChannel channel)
 {
     if (_logger.IsEnabled(LogEventLevel.Debug))
     {
         _logger.Debug("NetNode {@node} NetChannel {@channel} has disconnected", node, channel);
     }
 }
Example #6
0
 public void NetChannelRequestTimedOut(INetNode node, INetChannel channel, Message message, Guid requestId, int durationMs)
 {
     if (_logger.IsEnabled(LogEventLevel.Warning))
     {
         _logger.Warning("NetChannel {@channel} has timed out within {durationMs} ms on sending request {@message} {requestId}", channel, durationMs, message, requestId);
     }
 }
 public AsyncProcessingNetChannel(Func<IMessageProcessingPipeBuilder, IMessageProcessingPipeBuilder> configureProcesssingPipe, INetNode node,
     ITransportChannel transportChannel, IMessageSerializer serializer, ICoreEvents logger, INetNodeConfig config, IBufferPool bufferPool)
     : base(node, transportChannel, serializer, logger, config, bufferPool)
 {
     _pipeBuilder = configureProcesssingPipe(new MessageProcessingPipeBuilder());
     _processor = _pipeBuilder.Build();
 }
Example #8
0
 public void CantReplyToOneWayMessage(INetNode node, IOperationContext operation)
 {
     if (_logger.IsEnabled(LogEventLevel.Debug))
     {
         _logger.Warning("NetChannel {@channel} is trying to reply to one way message {@message}", operation.ReplyChannel, operation.Message);
     }
 }
Example #9
0
 public void NetChannelIsDisposing(INetNode node, INetChannel channel)
 {
     if (_logger.IsEnabled(LogEventLevel.Debug))
     {
         _logger.Debug("NetChannel {@channel} is closing", channel);
     }
 }
Example #10
0
 public void NodeUpdateLoopError(INetNode node, Exception exception)
 {
     if (_logger.IsEnabled(LogEventLevel.Error))
     {
         _logger.Error("NetNode {@node} unexpected exception {@exception}", node, exception);
     }
 }
        public NetChannel(INetNode node, ITransportChannel transportChannel, IMessageSerializer serializer, ICoreEvents logger, INetNodeConfig config, IBufferPool bufferPool)
        {
            _onOperationSubject          = new Subject <OperationContext>();
            _onDisconnectedSubject       = new Subject <INetChannel>();
            PendingOperationsByRequestId = new ConcurrentDictionary <Guid, PendingOperation>();

            TransportChannel = transportChannel;
            var metricContext = Metric.Context(node.InstanceName);

            _receivedMessagesMeter = metricContext.Meter("ReceivedMessagesMeter", Unit.Requests);
            _sentMessagesMeter     = metricContext.Meter("SentMessagesMeter", Unit.Requests);
            _requestsMeter         = metricContext.Meter("SentRequestsMeter", Unit.Requests);
            _requestsFailedMeter   = metricContext.Meter("SentRequestsFailedMeter", Unit.Requests);
            _requestDurationTimer  = metricContext.Timer("SentRequestsDurationTimer", Unit.Requests, durationUnit: TimeUnit.Milliseconds);


            Node        = node;
            Logger      = logger;
            _config     = config;
            _bufferPool = bufferPool;

            MessageSerializer = serializer;
            IsConnected       = true;
            transportChannel.Bind(ProcessIncomingRequest, Dispose);
        }
Example #12
0
 public void OperationProcessed(INetNode node, INetChannel channel, IOperationContext operation)
 {
     if (_logger.IsEnabled(LogEventLevel.Information))
     {
         _logger.Information("NetNode {@node} on NetChannel {@channel} processed {@operation}", node, channel, operation);
     }
 }
Example #13
0
 public void NodeUpdateLoopStarted(INetNode node)
 {
     if (_logger.IsEnabled(LogEventLevel.Information))
     {
         _logger.Information("Update loop of NetNode {@node} has started", node);
     }
 }
Example #14
0
 public void NetChannelSentMessage(INetNode node, INetChannel channel, Message message)
 {
     if (_logger.IsEnabled(LogEventLevel.Debug))
     {
         _logger.Debug("NetChannel {@channel} has sent message {@message}", channel, message);
     }
 }
Example #15
0
        private void HandleGamePacket(object sender, PacketEventArgs e)
        {
            INetNode node = (INetNode)sender;

            if (e.Type == PacketType.Connect)
            {
                if (e.Data.Length != 0)
                {
                    return;
                }
                byte[] data = new byte [8];
                BitConv.ToInt32(data, 0, nodes.IndexOf(node));
                BitConv.ToInt32(data, 4, nodes.Count);
                node.SendPacket(PacketType.Accepted, data);
            }
            else if (e.Type == PacketType.DoomData)
            {
                if (e.Data.Length < 4)
                {
                    return;
                }
                int nodeid = BitConv.FromInt32(e.Data, 0);
                if (nodeid < 0 || nodeid >= nodes.Count)
                {
                    return;
                }
                byte[] data = new byte [e.Data.Length];
                BitConv.ToInt32(data, 0, nodes.IndexOf(node));
                Array.Copy(e.Data, 4, data, 4, e.Data.Length - 4);
                nodes[nodeid].SendPacket(PacketType.DoomData, data);
            }
        }
Example #16
0
 public void NodeStopped(INetNode node)
 {
     if (_logger.IsEnabled(LogEventLevel.Warning))
     {
         _logger.Warning("NetNode {@node} has stopped", node);
     }
 }
Example #17
0
 public void ConnectingTo(INetNode node, IPEndPoint address)
 {
     if (_logger.IsEnabled(LogEventLevel.Debug))
     {
         _logger.Debug("NetNode {@node} is trying to connect to {@address}", node, address);
     }
 }
Example #18
0
 public void OperationProcessingFailed(INetNode node, INetChannel channel, IOperationContext operation, Exception exception)
 {
     if (_logger.IsEnabled(LogEventLevel.Warning))
     {
         _logger.Warning("NetNode {@node} on NetChannel {@channel} failed to process operation {@operation} with {@exception}", node, channel, operation, exception);
     }
 }
Example #19
0
 public void NetChannelRequestCompleted(INetNode node, INetChannel channel, Message message, Guid requestId, int durationMs)
 {
     if (_logger.IsEnabled(LogEventLevel.Information))
     {
         _logger.Information("NetNode {@node} NetChannel {@channel} is received reply {@message} for {requestId} in {durationMs} ms", node, channel, message, requestId, durationMs);
     }
 }
Example #20
0
 public void ConnectionSucceeded(INetNode node, IPEndPoint address, INetChannel channel, int durationMs)
 {
     if (_logger.IsEnabled(LogEventLevel.Information))
     {
         _logger.Information("NetNode {@node} has connected to {@address} with {@channel} in {durationMs} ms", node, address, channel, durationMs);
     }
 }
Example #21
0
 public void NetChannelRequestStarted(INetNode node, INetChannel channel, Message request, Guid requestId)
 {
     if (_logger.IsEnabled(LogEventLevel.Debug))
     {
         _logger.Debug("NetNode {@node} on NetChannel {@channel} sending request {@message} with id {requestId}", node, channel, request, requestId);
     }
 }
Example #22
0
 public void NetChannelSentReplyMessage(INetNode node, INetChannel channel, Message reply, IOperationContext operation)
 {
     if (_logger.IsEnabled(LogEventLevel.Debug))
     {
         _logger.Debug("NetNode {@node} on NetChannel {@channel} sent reply {@message} for operation {@operation}", node, channel, reply, operation);
     }
 }
Example #23
0
        private void HandleJoinPacket(object sender, PacketEventArgs e)
        {
            INetNode node = (INetNode)sender;

            if (e.Type == PacketType.Connect)
            {
                node.SendPacket(PacketType.Waiting, new byte [0]);
            }
        }
Example #24
0
        /// <summary>
        /// Creates a new directed NetEdge from the origin to the destination.
        /// </summary>
        /// <param name="origin">The node that the edge emits from.</param>
        /// <param name="destination">The node that the edge points to.</param>
        /// <param name="isBidirectional">
        /// Returns true if there exists an edge pointing the opposite direction.
        /// </param>
        public NetEdge(INetNode origin, INetNode destination, bool isBidirectional)
        {
            origin.AssertNotNull(nameof(origin));
            destination.AssertNotNull(nameof(destination));

            this.origin = origin;
            this.destination = destination;
            this.isBidirectional = isBidirectional;
        }
Example #25
0
        /// <summary>
        /// Creates a new directed NetEdge from the origin to the destination.
        /// </summary>
        /// <param name="origin">The node that the edge emits from.</param>
        /// <param name="destination">The node that the edge points to.</param>
        /// <param name="isBidirectional">
        /// Returns true if there exists an edge pointing the opposite direction.
        /// </param>
        public NetEdge(INetNode origin, INetNode destination, bool isBidirectional)
        {
            origin.AssertNotNull(nameof(origin));
            destination.AssertNotNull(nameof(destination));

            this.origin          = origin;
            this.destination     = destination;
            this.isBidirectional = isBidirectional;
        }
Example #26
0
        /// <summary>
        /// Creates a new NetGraph representation from raw data.
        /// </summary>
        /// <param name="nodes">
        /// A list of all nodes. The first node is assumed to be this computer.
        /// </param>
        private NetGraph(IEnumerable <INetNode> nodes)
        {
            nodes.AssertNotNull(nameof(nodes));

            if (nodes.FirstOrDefault() != null)
            {
                this.thisNode = nodes.First();
            }

            this.nodes = nodes.ToImmutableDictionary(edge => edge.Guid, edge => edge);
        }
        async static Task Run(INetNode node)
        {
            node.Start();
            Console.WriteLine("Input server endpoint in form of ipaddress:port");
            string[] addressAndPort = Console.ReadLine().Split(':');
            var      endpoint       = new IPEndPoint(IPAddress.Parse(addressAndPort[0]), int.Parse(addressAndPort[1]));

            //before doing any network comms we should connect to some server node
            using (INetChannel channel = await node.Connect(endpoint))
            {
                await Task.Yield();

                Console.WriteLine("Enter your name");
                string name = Console.ReadLine();

                Console.WriteLine("Enter chat room name");
                string roomName = Console.ReadLine();

                //using connected channel we can send in request/reply pattern
                JoinRoomResponse response = await channel.SendRequestAsync <JoinRoomResponse>(
                    new JoinRoom
                {
                    ClientName = name,
                    RoomName   = roomName
                });

                if (response.RetCode == JoinRoomRetCode.NameIsTaken)
                {
                    Console.WriteLine("Name is taken");
                    return;
                }

                Console.WriteLine("You are connected, say something or enter exit");

                bool exit = false;
                while (!exit)
                {
                    await Task.Yield(); //client uses single threaded processing, so it's better noto block it with Console.Readline

                    string text = Console.ReadLine();
                    if (text == "exit")
                    {
                        exit = true;
                    }
                    else
                    {
                        //or we can send just one way messages
                        channel.Send(new Say {
                            Text = text
                        });
                    }
                }
            }
        }
Example #28
0
        /// <summary>
        /// Creates a new NetGraph representation from raw data.
        /// </summary>
        /// <param name="nodes">
        /// A list of all nodes. The first node is assumed to be this computer.
        /// </param>
        private NetGraph(IEnumerable<INetNode> nodes)
        {
            nodes.AssertNotNull(nameof(nodes));

            if (nodes.FirstOrDefault() != null)
            {
                this.thisNode = nodes.First();
            }

            this.nodes = nodes.ToImmutableDictionary(edge => edge.Guid, edge => edge);
        }
        NetChannel CreatePeer(INetNode node, ITransportChannel transport)
        {
            var peer = new AsyncProcessingNetChannel(builder => builder
                                                     .UseFiber(_fiber)
                                                     .UseConfigurableClientDispatcher((handlersBuilder) =>
            {
                _messageHandlingConfigurator(handlersBuilder);
                return(handlersBuilder);
            }), node, transport, MessageSerializer, Logger, Config, _bufferPool);

            return(peer);
        }
        async static Task Run(INetNode node)
        {
            node.Start();
            Console.WriteLine("Input server endpoint in form of ipaddress:port");
            string[] addressAndPort = Console.ReadLine().Split(':');
            var endpoint = new IPEndPoint(IPAddress.Parse(addressAndPort[0]), int.Parse(addressAndPort[1]));

            //before doing any network comms we should connect to some server node
            using (INetChannel channel = await node.Connect(endpoint))
            {
                await Task.Yield();
                Console.WriteLine("Enter your name");
                string name = Console.ReadLine();

                Console.WriteLine("Enter chat room name");
                string roomName = Console.ReadLine();

                //using connected channel we can send in request/reply pattern
                JoinRoomResponse response = await channel.SendRequestAsync<JoinRoomResponse>(
                    new JoinRoom
                    {
                        ClientName = name,
                        RoomName = roomName
                    });

                if (response.RetCode == JoinRoomRetCode.NameIsTaken)
                {
                    Console.WriteLine("Name is taken");
                    return;
                }

                Console.WriteLine("You are connected, say something or enter exit");

                bool exit = false;
                while (!exit)
                {
                    await Task.Yield(); //client uses single threaded processing, so it's better noto block it with Console.Readline
                    string text = Console.ReadLine();
                    if (text == "exit")
                    {
                        exit = true;
                    }
                    else
                    {
                        //or we can send just one way messages
                        channel.Send(new Say {Text = text});
                    }
                }
            }
        }
 public AzureEventHubActorSystem(ushort id, string hubName, string hubConnectionString, string blobStorageConnectionString, bool shouldProcessEvents,
                                 Func <TActor> actorFactory, INetNodeConfig config,
                                 INetNode serverNode, IMessageSerializer serializer, IAzureEventHubActorSystemEvents logger, TimeSpan checkpointEveryTimespan)
 {
     _id = id;
     _hubConnectionString         = hubConnectionString;
     _blobStorageConnectionString = blobStorageConnectionString;
     _shouldProcessEvents         = shouldProcessEvents;
     _actorFactory            = actorFactory;
     _config                  = config;
     _serverNode              = serverNode;
     _serializer              = serializer;
     _logger                  = logger;
     _checkpointEveryTimespan = checkpointEveryTimespan;
     _hubName                 = hubName;
     _consumerGroup           = typeof(TActor).Name;
 }
Example #32
0
        private INetNode[] GetNetworkNodes()
        {
            var            netNodes = new INetNode[_netMap.Count];
            int            index    = 0;
            ActivationType actType  = ActivationType.IDENTITY;

            foreach (var nodeMap in _netMap.Keys)
            {
                //var genomeNode = _genome.NodeList[nodeMap.NeuronId];
                var genomeNode = _genome.NodeList.First(n => n.Idx == nodeMap.NeuronId);

                switch (genomeNode.ActivationType)
                {
                case NodeActivationType.NONE:
                    actType = ActivationType.IDENTITY;
                    break;

                case NodeActivationType.LEAKYRELU:
                    actType = ActivationType.LEAKYRELU;
                    break;

                case NodeActivationType.SIGMOID:
                    actType = ActivationType.SIGMOID;
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(NodeActivationType), genomeNode.ActivationType, null);
                }
                if (genomeNode.NodeType == NodeGeneType.BIAS)
                {
                    actType = ActivationType.BIAS;
                }

                netNodes[index] = new NetNode(actType);
                index++;
            }

            return(netNodes);
        }
Example #33
0
 public SFChatClientNetChannel(INetNode node, ITransportChannel transportChannel, IMessageSerializer serializer, ICoreEvents logger, INetNodeConfig config, IBufferPool bufferPool)
     : base(node, transportChannel, serializer, logger, config, bufferPool)
 {
 }
Example #34
0
 public NetCommunicationClientFactory(INetNode netNode, IServicePartitionResolver servicePartitionResolver = null, IEnumerable <IExceptionHandler> exceptionHandlers = null, string traceId = null)
     : base(servicePartitionResolver, AddExceptionHandler(exceptionHandlers), traceId)
 {
     _netNode = netNode;
 }
 public void OperationProcessed(INetNode node, INetChannel channel, IOperationContext operation)
 {
     if (_logger.IsEnabled(LogEventLevel.Information))
         _logger.Information("NetNode {@node} on NetChannel {@channel} processed {@operation}", node, channel, operation);
 }
 public void ConnectionSucceeded(INetNode node, IPEndPoint address, INetChannel channel, int durationMs)
 {
     if (_logger.IsEnabled(LogEventLevel.Information))
         _logger.Information("NetNode {@node} has connected to {@address} with {@channel} in {durationMs} ms", node, address, channel, durationMs);
 }
 public void NetChannelRequestStarted(INetNode node, INetChannel channel, Message request, Guid requestId)
 {
     if (_logger.IsEnabled(LogEventLevel.Debug))
         _logger.Debug("NetNode {@node} on NetChannel {@channel} sending request {@message} with id {requestId}", node, channel, request, requestId);
 }
 public void NetChannelSentReplyMessage(INetNode node, INetChannel channel, Message reply, IOperationContext operation)
 {
     if (_logger.IsEnabled(LogEventLevel.Debug))
         _logger.Debug("NetNode {@node} on NetChannel {@channel} sent reply {@message} for operation {@operation}", node, channel, reply, operation);
 }
 public void CantReplyToOneWayMessage(INetNode node, IOperationContext operation)
 {
     if (_logger.IsEnabled(LogEventLevel.Debug))
         _logger.Warning("NetChannel {@channel} is trying to reply to one way message {@message}", operation.ReplyChannel, operation.Message);
 }
 public void OperationProcessingFailed(INetNode node, INetChannel channel, IOperationContext operation, Exception exception)
 {
     if (_logger.IsEnabled(LogEventLevel.Warning))
         _logger.Warning("NetNode {@node} on NetChannel {@channel} failed to process operation {@operation} with {@exception}", node, channel, operation, exception);
 }
 public void NetChannelRequestFailed(INetNode node, NetChannel channel, ErrorMessage error, Guid requestId, int durationMs)
 {
     if (_logger.IsEnabled(LogEventLevel.Warning))
         _logger.Warning("NetNode {@node} NetChannel {@channel} sent request failed with {@error} for {requestId} in {durationMs} ms", node, channel, error, requestId, durationMs);
 }
 public void ActorActivated(INetNode node, ActorKey actorKey)
 {
     if (_logger.IsEnabled(LogEventLevel.Information))
         _logger.Information("actor:{@actorKey} is activated on node:{@node}", actorKey, node);
 }
 public void NetChannelRequestTimedOut(INetNode node, INetChannel channel, Message message, Guid requestId, int durationMs)
 {
     if (_logger.IsEnabled(LogEventLevel.Warning))
         _logger.Warning("NetChannel {@channel} has timed out within {durationMs} ms on sending request {@message} {requestId}", channel, durationMs, message, requestId);
 }
 public void ConnectionHasTimedOut(INetNode node, IPEndPoint address)
 {
     if (_logger.IsEnabled(LogEventLevel.Warning))
         _logger.Warning("NetNode {@node} has failed to connect to {@address} within alloted time", node, address);
 }
Example #45
0
 public ServiceFabricCommunicationListenerAdapter(INetNode netNode, string transportSchema = "net.tcp")
 {
     _netNode         = netNode;
     _transportSchema = transportSchema;
 }
 public void ConnectingTo(INetNode node, IPEndPoint address)
 {
     if (_logger.IsEnabled(LogEventLevel.Debug))
         _logger.Debug("NetNode {@node} is trying to connect to {@address}", node, address);
 }
 public SFChatClientNetChannel(INetNode node, ITransportChannel transportChannel, IMessageSerializer serializer, ICoreEvents logger, INetNodeConfig config, IBufferPool bufferPool)
     : base(node, transportChannel, serializer, logger, config, bufferPool)
 {
 }
 public void NetChannelDisconnected(INetNode node, INetChannel channel)
 {
     if (_logger.IsEnabled(LogEventLevel.Debug))
         _logger.Debug("NetNode {@node} NetChannel {@channel} has disconnected", node, channel);
 }
 public void NetChannelIsDisposing(INetNode node, INetChannel channel)
 {
     if (_logger.IsEnabled(LogEventLevel.Debug))
         _logger.Debug("NetChannel {@channel} is closing", channel);
 }
 public void NodeUpdateLoopError(INetNode node, Exception exception)
 {
     if (_logger.IsEnabled(LogEventLevel.Error))
         _logger.Error("NetNode {@node} unexpected exception {@exception}", node, exception);
 }
 public void NetChannelRequestCompleted(INetNode node, INetChannel channel, Message message, Guid requestId, int durationMs)
 {
     if (_logger.IsEnabled(LogEventLevel.Information))
         _logger.Information("NetNode {@node} NetChannel {@channel} is received reply {@message} for {requestId} in {durationMs} ms", node, channel, message, requestId, durationMs);
 }
 public void NodeStopped(INetNode node)
 {
     if (_logger.IsEnabled(LogEventLevel.Warning))
         _logger.Warning("NetNode {@node} has stopped", node);
 }
 public MouseActorsBackendClientNetChannel(IActorSystem<ITestActor> actorSystem, INetNode node, ITransportChannel transportChannel, IMessageSerializer serializer, 
     ICoreEvents logger, INetNodeConfig config, IBufferPool bufferPool)
     : base(node, transportChannel, serializer, logger, config, bufferPool)
 {
     _actorSystem = actorSystem;
 }
 public void NodeUpdateLoopStarted(INetNode node)
 {
     if (_logger.IsEnabled(LogEventLevel.Information))
         _logger.Information("Update loop of NetNode {@node} has started", node);
 }
 public void NetChannelSentMessage(INetNode node, INetChannel channel, Message message)
 {
     if (_logger.IsEnabled(LogEventLevel.Debug))
         _logger.Debug("NetChannel {@channel} has sent message {@message}", channel, message);
 }
 public ServiceFabricCommunicationListenerAdapter(INetNode netNode, string transportSchema = "net.tcp")
 {
     _netNode = netNode;
     _transportSchema = transportSchema;
 }