Exemple #1
0
        private void ReceivedMessage(TcpConnection connection, object obj)
        {
            string m  = obj as string;
            string fm = string.Format("{0} : {1}", connection.ToString(), m);

            PrintLine(fm);
            server.Broadcast(fm);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("========== OSPREY SERVER ==========");

            using (Osprey.Default())
                using (Osprey.Join("osprey.server"))
                    using (var tcp = new TcpServer("mango"))
                    {
                        StartSendingHttp();

                        Task.Run(() =>
                        {
                            while (true)
                            {
                                tcp.Broadcast(Guid.NewGuid().ToString());
                                Thread.Sleep(100);
                            }
                        });

                        while (true)
                        {
                            Thread.Sleep(1000);
                        }
                    }
        }
Exemple #3
0
        static void Main()
        {
            IPEndPoint endpoint = new IPEndPoint(IPAddress.Loopback, 6002);

            server.ProtocolFactory          = WebSocketsSelectorProcessor.Default;
            server.ConnectionTimeoutSeconds = 60;
            server.MaxOutgoingQuota         = 640000;
            server.Received += msg => {
                redis.GetSubscriber()
                .Publish(new RedisChannel("request", RedisChannel.PatternMode.Auto),
                         msg.Value.ToString());
            };
            redis.GetSubscriber()
            .Subscribe(new RedisChannel("response", RedisChannel.PatternMode.Auto),
                       (channel, value) => server.Broadcast(value.ToString()));


            server.Start("abc", endpoint);
            Console.WriteLine("Server running");

            Console.ReadKey();

            Console.WriteLine("Server dead; press any key");
            Console.ReadKey();
        }
 public void BroadcastNotification(string notificationName)
 {
     if (!running)
     {
         return;
     }
     webSocketServer.Broadcast(JsonConvert.SerializeObject(new
     {
         eventType = WebGuiEventType.Notification,
         eventData = new
         {
             name = notificationName
         }
     }));
 }