Example #1
0
        private void UdpServerForm_Load(object sender, EventArgs e)
        {
            //Port = DEFAULT_PORT;
            //var ip = IPAddress.Any;

            //Console.WriteLine("Starting echo server...");
            //Console.WriteLine("Will begin listening for requests on {0}:{1}", ip, Port);
            //var bootstrapper =
            //    new ServerBootstrap()
            //        .WorkerThreads(2)
            //        .SetTransport(TransportType.Udp);
            //var reactor = bootstrapper.NewReactor(NodeBuilder.BuildNode().Host(ip).WithPort(Port));
            //reactor.OnConnection += (node, connection) =>
            //{
            //    ServerPrint(node,
            //        string.Format("Accepting connection from... {0}:{1}", node.Host, node.Port));
            //    connection.BeginReceive(Receive);
            //};
            //reactor.OnDisconnection += (reason, address) => ServerPrint(address.RemoteHost,
            //    string.Format("Closed connection to... {0}:{1} [Reason:{2}]", address.RemoteHost.Host,
            //        address.RemoteHost.Port, reason.Type));

            //reactor.Start();
            IConnectionConfig connectionConfig = new DefaultConnectionConfig();

            connectionConfig.SetOption(WebSocketParamEumns.Port.ToString(), 8088);
            var bootstrapper = new PushBootstrap()
                               .SetPushType(PushTypeEumns.WebSocket)
                               .WorkerThreads(2)
                               .BuildPushServerFactory <WebSocketNotifications>();
            IPushBroker <WebSocketNotifications> pushBroker = bootstrapper.NewPushBroker(connectionConfig) as IPushBroker <WebSocketNotifications>;

            pushBroker.OnConnection += PushBroker_OnNewConnection;
            pushBroker.Start();
        }
Example #2
0
 protected AbstractBootstrap()
 {
     Config    = new DefaultConnectionConfig();
     Encoder   = Encoders.DefaultEncoder;
     Decoder   = Encoders.DefaultDecoder;
     Allocator = UnpooledByteBufAllocator.Default;
     Type      = TransportType.Tcp;
 }
Example #3
0
 protected AbstractBootstrap()
 {
     Config       = new DefaultConnectionConfig();
     Encoder      = Encoders.DefaultEncoder;
     Decoder      = Encoders.DefaultDecoder;
     Allocator    = new DefaultByteBufAllocator();
     ReactorTypes = ReactorType.SerialPorts;
 }
Example #4
0
 protected AbstractBootstrap()
 {
     Config = new DefaultConnectionConfig();
     Encoder = Encoders.DefaultEncoder;
     Decoder = Encoders.DefaultDecoder;
     Allocator = UnpooledByteBufAllocator.Default;
     Type = TransportType.Tcp;
 }