Example #1
0
        public static void Subscribe(this TcpService tcpInfo, Action <object> messageHandler)
        {
            var endpoint = Address.GenerateTcpEndpoint();
            var client   = new TcpClient(endpoint);

            Console.WriteLine("Connecting to server...");
            client.Connect(IPEndPoint.Parse(tcpInfo.Endpoint.Address));
            TempConnection = new TcpConnection(client, endpoint.ToString());

            TempConnection.OnMessage += messageHandler;
        }
Example #2
0
        public TcpServer(string endpoint)
        {
            var ipEndpoint = Address.GenerateTcpEndpoint();

            Listener    = new TcpListener(ipEndpoint);
            Connections = new ConcurrentBag <TcpConnection>();

            StartAsync();

            var hostInfo = new TcpService(new Endpoint()
            {
                Name    = endpoint,
                Address = ipEndpoint.ToString()
            });

            Osprey.Node.Register(hostInfo);
        }