Beispiel #1
0
        private void EstablishConnectionToLogServer()
        {
            RequestConnectionMessage request = new RequestConnectionMessage(ExectuableName, ClientSessionKey);

            Utility.WebUtility.BroadcastMessage(LogServerBroadcastPort, Utility.SerializeUtility.SerializeToJsonString(request));
            Console.WriteLine(Utility.SerializeUtility.SerializeToJsonString(request));
            //Message m = (Message)Utility.SerializeUtility.DeserializeJsonString(Utility.SerializeUtility.SerializeToJsonString(request));
        }
        private void MessageReceived(object sender, Utility.WebUtility.MessageReceivedEventArgs args)
        {
            Console.WriteLine(args.Message);
            Message incomingMessage = Utility.SerializeUtility.DeserializeJsonString <Message>(args.Message);

            if (incomingMessage.Type == MessageType.RequestConnection)
            {
                RequestConnectionMessage message = Utility.SerializeUtility.DeserializeJsonString <RequestConnectionMessage>(args.Message);
                Console.WriteLine(message.Type + " " + args.RemoteEndpoint.Address);
            }
        }
        private void EstablishConnectionToLogServer()
        {
            for (int attemptNum = 0; attemptNum < MAX_CONNECTION_ATTEMPT; attemptNum++)
            {
                uint clientSessionKey            = (uint)string.Format("{0}{1}{2}", DateTime.Now.ToString(), new Random().NextDouble().ToString(), this.ApplicationName).GetHashCode();
                RequestConnectionMessage request = new RequestConnectionMessage(ApplicationName, clientSessionKey);

                Utility.WebUtility.BroadcastMessage(LogServerBroadcastPort, Utility.SerializeUtility.SerializeToJsonString(request));
                Console.WriteLine(Utility.SerializeUtility.SerializeToJsonString(request));
            }


            //Message m = (Message)Utility.SerializeUtility.DeserializeJsonString(Utility.SerializeUtility.SerializeToJsonString(request));
        }