Пример #1
0
 public override Task <HelloMessage> SayHello(HelloMessage request, ServerCallContext context)
 {
     _parent._receivedMessage = request.Message;
     return(Task.FromResult(new HelloMessage {
         Message = "Thank You!"
     }));
 }
Пример #2
0
        private async Task HandleHelloAsync(string json)
        {
            HelloMessage hello = JsonSerializer.Deserialize <HelloMessage>(json, DefaultJsonSerializerOptions);

            string negotiatedProtocol = hello
                                        .Protocols
                                        .Intersect(SupportedProtocols)
                                        .OrderByDescending(x => x)
                                        .FirstOrDefault();

            if (negotiatedProtocol == null)
            {
                string incompatibleMessage =
                    "No compatible LiveReload protocols found, aborting connection " +
                    $"(client: {string.Join(", ", hello.Protocols)}, " +
                    $"server: {string.Join(", ", SupportedProtocols)})";
                _isConnected = false;
                await _webSocket.CloseAsync(WebSocketCloseStatus.ProtocolError, incompatibleMessage, CancellationToken.None);

                return;
            }

            // If we support the protocol, send hello and consider this socket connected
            await SendHelloMessageAsync();

            _isConnected = true;
        }
Пример #3
0
        public void Handle(HelloMessage message)
        {
            Debug.WriteLine($"Handle(HelloMessage message)/{message.UiAsync}/{message.msg}");
            if (message.UiAsync)
            {
                Execute.OnUIThreadAsync(() =>
                {
                    _myText = message.msg;
                    MyText  = _myText;
                });

                /*Execute.OnUIThread(() =>
                 * {
                 *  _myText = message.msg;
                 *  MyText = _myText;
                 *
                 * });*/
            }
            else
            {
                _myText = message.msg;
                MyText  = _myText;
            }

            NotifyOfPropertyChange(() => MyText);
        }
Пример #4
0
        private void ButtonHello_Click(object sender, EventArgs e)
        {
            var helloMessage = new HelloMessage();
            var message      = helloMessage.GetHelloMessage(_entryName.Text);

            _lableMessage.Text = helloMessage.GetHelloMessage(_entryName.Text);
        }
Пример #5
0
        static async Task <int> _RunAsync(Options options)
        {
            // https://github.com/naudio/NAudio/blob/master/Docs/OutputDeviceTypes.md
            Device device = _GetDevice(options);

            if (options.ListDevices)
            {
                string[] deviceList = device.List().ToArray();
                foreach (string d in deviceList)
                {
                    Console.WriteLine(d);
                }

                return(0);
            }

            HelloMessage helloMessage = new HelloMessage(_GetMacAddress(), _GetOS(), options.Instance);

            helloMessage.Version = string.Join(".", s_Version.Major, s_Version.Minor, s_Version.Build);
            Player     player     = new NAudioPlayer(options.DacLatency, options.BufferDurationMs, options.OffsetToleranceMs, device.DeviceFactory);
            Controller controller = new Controller(player, helloMessage);

            await controller.StartAsync(options.HostName, options.Port);

            return(0);
        }
Пример #6
0
        public IActionResult PostBonjourForm(string language = "English", string name = "Anonymous")
        {
            //get the greeting cookie and increment
            string cookieName    = "greetings";
            int    greetingCount = 0;
            string cookieCount;

            if (Request.Cookies.TryGetValue(cookieName, out cookieCount))
            {
                greetingCount = int.Parse(cookieCount);
            }
            greetingCount += 1;

            // build the html response
            StringBuilder html = new StringBuilder();

            html.Append("<h1 style ='color:red;font-family:Arial;' />")
            .Append(HelloMessage.CreateMessage(language, name))
            .Append(string.Format("<h2>{0} total greetings have been generated!</h2>", greetingCount))
            .Append("</h1>");

            // set the greetings cookie
            Response.Cookies.Append(cookieName, greetingCount.ToString());

            return(Content(html.ToString(), "text/html"));
        }
Пример #7
0
        public void Can_do_roundtrip()
        {
            HelloMessage helloMessage = new HelloMessage();

            helloMessage.P2PVersion   = 1;
            helloMessage.Capabilities = new List <Capability>();
            helloMessage.Capabilities.Add(new Capability(Protocol.Eth, 1));
            helloMessage.ClientId   = "Nethermind/alpha";
            helloMessage.ListenPort = 8002;
            helloMessage.NodeId     = NetTestVectors.StaticKeyA.PublicKey;

            HelloMessageSerializer serializer = new HelloMessageSerializer();

            byte[] serialized    = serializer.Serialize(helloMessage);
            byte[] expectedBytes = Bytes.FromHexString("f85e01904e65746865726d696e642f616c706861c6c58365746801821f42b840fda1cff674c90c9a197539fe3dfb53086ace64f83ed7c6eabec741f7f381cc803e52ab2cd55d5569bce4347107a310dfd5f88a010cd2ffd1005ca406f1842877");

            Assert.True(Bytes.AreEqual(serialized, expectedBytes), "bytes");

            HelloMessage deserialized = serializer.Deserialize(serialized);

            Assert.AreEqual(helloMessage.P2PVersion, deserialized.P2PVersion);
            Assert.AreEqual(helloMessage.ClientId, deserialized.ClientId);
            Assert.AreEqual(helloMessage.NodeId, deserialized.NodeId);
            Assert.AreEqual(helloMessage.ListenPort, deserialized.ListenPort);
            Assert.AreEqual(helloMessage.Capabilities.Count, deserialized.Capabilities.Count);
            Assert.AreEqual(helloMessage.Capabilities[0].ProtocolCode, deserialized.Capabilities[0].ProtocolCode);
            Assert.AreEqual(helloMessage.Capabilities[0].Version, deserialized.Capabilities[0].Version);
        }
Пример #8
0
        private void handleHelloMessage(HelloMessage msg, IPAddress sender)
        {
            // see if the peers list contains a SyncPeer with the same hostname
            SyncPeer found = _peers.Find((peer) => { return(peer.Hostname == msg.hostname); });

            if (found != null)
            { // we know about this peer, update its last seen time
                found.LastResponded = DateTime.Now;
            }
            else
            { // we don't know about this peer, add it
                SyncPeer newPeer = new SyncPeer();
                newPeer.Port          = msg.listenPort;
                newPeer.Hostname      = msg.hostname;
                newPeer.Address       = sender;
                newPeer.LastResponded = DateTime.Now;
                _peers.Add(newPeer);
                Debug.WriteLine("Added new peer " + msg.hostname);

                SyncPeerUpdatedEventHandler handler = OnSyncPeerUpdated;
                if (handler != null)
                {
                    handler(this, new SyncPeerUpdatedEventArgs(found, SyncPeerUpdatedAction.Added));
                }

                // send our hello message quickly (so the peer doesn't have to wait ~5 seconds to get our next hello)
                _udpAgent.HurrySendHello();

                // request the peer's applist
                Debug.WriteLine("Sending RequestAppList to " + sender.ToString());
                RequestAppListMessage sendMsg = new RequestAppListMessage();
                _tcpAgent.SendMessage(sendMsg, sender);
            }
        }
Пример #9
0
        public void HelloMessageHandler(HelloMessage message)
        {
            var packedMessage = new IdentifyMessage()
            {
                Token            = "Bot " + DiscordClient.Instance.Token,
                ClientProperties = new IdentifyConnection()
                {
                    browser = "AlpaBot",
                    device  = "AlpaBot",
                    os      = "windows"
                },
                LargeThreshold = 250,
                Compress       = true,
                ShardInfo      = new ShardInfo()
                {
                    ShardCount = 1,
                    ShardId    = 0
                },
            };

            var msg = new BaseMessage()
            {
                Data   = packedMessage,
                OpCode = GatewayOpCode.Identify
            };

            DiscordClient.Send(msg);

            DiscordClient.Instance.Heartbeat = message.heartbeat_interval;
            DiscordClient.Instance.SetTimer();
        }
Пример #10
0
 private void onReceivedHelloR(HelloMessage helloMsg)
 {
     foreach (Pair pair in helloMsg.Pairs)
     {
         controller.addPair(pair);
     }
 }
Пример #11
0
 private static void HandleHelloMessage(NetworkClient client, HelloMessage message)
 {
     NetworkClient.Instance.SendMessage(new ClientVersionMessage
     {
         Version = Application.version
     });
 }
Пример #12
0
 public void AddHelloMesssage(HelloMessage helloMessage, PeerToPeerConnection connection)
 {
     Debug.Log("Manager of " + myClientName + ": Received Hello message from: " + helloMessage.name);
     sockets.Add(helloMessage.name, connection);
     peers.Add(helloMessage.name, helloMessage.ipAndPort);
     AddIncommingMessage(helloMessage);
 }
Пример #13
0
        public void Fire(BaseRtmResponse response)
        {
            AllMessages?.Invoke(this, new RtmMessageEventArgs <BaseRtmResponse>(response));

            switch (response)
            {
            case HelloResponse helloResponse:
                HelloMessage?.Invoke(this, new RtmMessageEventArgs <HelloResponse>(helloResponse));
                break;

            case PongResponse pongResponse:
                PongMessage?.Invoke(this, new RtmMessageEventArgs <PongResponse>(pongResponse));
                break;

            case UserTypingResponse userTypingResponse:
                UserTypingMessage?.Invoke(this, new RtmMessageEventArgs <UserTypingResponse>(userTypingResponse));
                break;

            case BaseMessageResponse messageResponse:
                switch (messageResponse)
                {
                case BotMessageResponse botMessageResponse:
                    BotMessage?.Invoke(this, new RtmMessageEventArgs <BotMessageResponse>(botMessageResponse));
                    break;

                default:
                    UserMessage?.Invoke(this, new RtmMessageEventArgs <UserMessageResponse>(messageResponse));
                    break;
                }
                break;

            default:
                throw new NotImplementedException();
            }
        }
Пример #14
0
 public Task <HelloMessageResult> HelloAsync(HelloMessage message)
 {
     return(Task.FromResult(new HelloMessageResult()
     {
         Result = $"Hello {message.Name}"
     }));
 }
Пример #15
0
        private void button1_Click(object sender, EventArgs e)
        {
            var helloMessage = new HelloMessage();
            var message      = helloMessage.GetHelloMessage(_textBoxName.Text);

            _buttonResult.Text = helloMessage.GetHelloMessage(_textBoxName.Text);
        }
Пример #16
0
        private void HelloResponse(HelloMessage message)
        {
            //Elaborates the Hello Message
            TempBuilding b = new TempBuilding();

            #region setting fields
            b.Address    = message.Address;
            b.Admin      = message.Admin;
            b.EnBought   = 0;
            b.EnSold     = 0;
            b.EnPeak     = message.EnPeak;
            b.EnPrice    = message.EnPrice;
            b.EnProduced = message.EnProduced;
            b.EnType     = message.EnType;
            b.Name       = message.header.Sender;
            b.status     = message.Status;
            b.iconPath   = b.status == PeerStatus.Producer ? @"/WPF_Resolver;component/img/producer.png" : @"/WPF_Resolver;component/img/consumer.png";
            #endregion

            lock (_lLock)
                _buildings.Add(b);

            XMLLogger.WriteLocalActivity("New Peer: " + b.Name + " is up!");

            //Be polite! Send an HelloResponse
            Connector.channel.HelloResponse(MessageFactory.createHelloResponseMessage("@All", Tools.getResolverName(), Tools.getResolverName()));
        }
Пример #17
0
 public Contact(IIdentity sender, HelloMessage env)
 {
     Machine = env.Machine;
     User    = env.User;
     Local   = env.Local;
     Remote  = env.Remote;
     Id      = (Unicast)sender.Uni;
 }
Пример #18
0
    static void Main()
    {
        Console.WriteLine("Привет!");

        HelloMessage v = new HelloMessage();

        v.Speak();
    }
        // POST: api/HelloWorld/Create
        public HttpResponseMessage Post(HelloMessage message)
        {
            //To be Implemented - Writing to the DB
            //throw new NotImplementedException();
            HttpResponseMessage response = Request.CreateResponse(_messageService.NewMessage(message));

            return(response);
        }
        public override Task <HelloMessage> SayHello(HelloMessage request, ServerCallContext context)
        {
            DebugWrite($"RpcCall 'SayHello': '{request}' from {context.Peer}");

            return(Task.FromResult(new HelloMessage {
                Version = _options.Version
            }));
        }
Пример #21
0
        /// <summary>
        /// Unit Test Method to return single object for HelloWorld class
        /// </summary>
        private HelloMessage GetTestHelloWorld()
        {
            var testHelloWorld = new HelloMessage()
            {
                Id = 1, Message = "Hello World"
            };

            return(testHelloWorld);
        }
Пример #22
0
        private void SayHello()
        {
            HelloMessage helloMessage = new HelloMessage
            {
                Protocols = _supportedVersion
            };

            SendObject(helloMessage);
        }
Пример #23
0
    static void Main()
    {
        
        Console.WriteLine("Hello world");
        MessageBox.Show("Hello world");

        HelloMessage h = new HelloMessage();
        h.Speak();
    }
Пример #24
0
    public static void Main()
    {
        // System.Console.WriteLine("Testing! 1, 2, 3");

        // Add this!
        // MessageBox.Show("Hello...");
        HelloMessage h = new HelloMessage();

        h.Speak();
    }
Пример #25
0
 /// <summary>
 /// Create a new ZreMsgOriginal
 /// </summary>
 public ZreMsgOriginal()
 {
     Hello   = new HelloMessage();
     Whisper = new WhisperMessage();
     Shout   = new ShoutMessage();
     Join    = new JoinMessage();
     Leave   = new LeaveMessage();
     Ping    = new PingMessage();
     PingOk  = new PingOkMessage();
 }
Пример #26
0
        static void Main(string[] args)
        {
            Console.WriteLine("testing 1, 2, 3");

            /***************************************/
            //System.Windows.Forms.MessageBox.Show("Hello...");
            HelloMessage h = new HelloMessage();

            h.Speak();
        }
Пример #27
0
    static void Main()
    {
        Console.WriteLine("Testing or summat");

/*continuing example
 *  MessageBox.Show("Moooore testing!");*/
        HelloMessage h = new HelloMessage();

        h.Speak();
    }
        public void Handle(BotMessage message)
        {
            var msg   = message.Message as GetPeerListReplyMessage;
            var hello = new HelloMessage();

            foreach (var peer in msg.Peers)
            {
                _messageManager.Send(hello, peer.BotId, 0);
            }
        }
Пример #29
0
    static void Main()
    {
        Console.WriteLine("Testing! 1, 2, 3");

        // Don't need this anymore either.
        // MessageBox.Show("Hello...");

        // Use the HelloMessage class!
        HelloMessage h = new HelloMessage();
        h.Speak();
    }
Пример #30
0
    static void Main()
    {
        Console.WriteLine("���ԣ� 1, 2, 3");

        // ������Ҫ����
        // MessageBox.Show("Hello...");

        // ʹ�� HelloMessage ��
        HelloMessage h = new HelloMessage();
        h.Speak();
    }
Пример #31
0
        public void Bootstrap(List<PeerInfo> peers)
        {
            Logger.Info(0, "Bootstrapping init.  {0} found endpoints", peers.Count);
            foreach (var peer in peers)
            {
                _peerList.TryRegister(peer);

                var hello = new HelloMessage();
                _messagesManager.Send(hello, peer.BotId, 0);
            }
        }
Пример #32
0
        public void HelloMessage()
        {
            StreamWriter writer = new StreamWriter(stream);
            HelloMessage msg    = new HelloMessage {
                Name = Name
            };

            writer.Write(msg.ToFullString());
            writer.WriteLine();
            writer.Flush();
        }
Пример #33
0
    public static void Main()
    {
        Console.WriteLine("Testing! 1, 2, 3");
        // Don't need this anymore either.
        // MessageBox.Show("Hello...");

        // Exercise the HelloMessage class!
        HelloMessage h = new HelloMessage();

        h.Speak();
    }
Пример #34
0
		/// <summary>
		/// Create a new ZreMsg
		/// </summary>
		public ZreMsg()
		{    
			Hello = new HelloMessage();
			Whisper = new WhisperMessage();
			Shout = new ShoutMessage();
			Join = new JoinMessage();
			Leave = new LeaveMessage();
			Ping = new PingMessage();
			PingOk = new PingOkMessage();
		}			
Пример #35
0
 static void Main()
 {
     Console.WriteLine("Это тест! Три два раз 1 2 3");
     HelloMessage h = new HelloMessage();
     h.Speak();
 }