void Receive() { NetworkStream networkStream = new NetworkStream(this.ClientSocket); while (true) { Postman postMan = Postman.GetPackage(networkStream); Console.WriteLine(postMan); switch (postMan.Type) { case Postman.PostmanType.SEND_KEY: this.ServerMysterio.PubKey = Mysterio.ConvertBytesToKey(postMan.Payload); break; case Postman.PostmanType.SEND_MESSAGE: string plainText = Mysterio.Decrypt(this.ClientMysterio.PriKey, postMan.Payload); Console.WriteLine(plainText); break; } if (postMan.Type == Postman.PostmanType.DISCONNECT) { break; } } networkStream.Close(); }
void Send() { NetworkStream networkStream = new NetworkStream(this.ClientSocket); while (true) { string str = Console.ReadLine(); Postman postMan = new Postman(); switch (str.ToUpper()) { case "SEND_KEY": postMan.Type = Postman.PostmanType.SEND_KEY; postMan.Payload = Mysterio.ConvertKeyToBytes(this.ClientMysterio.PubKey); break; default: postMan.Type = Postman.PostmanType.SEND_MESSAGE; postMan.Payload = Mysterio.Encrypt(this.ServerMysterio.PubKey, str); break; } Postman.SendPackage(networkStream, postMan); if (str.ToUpper().Equals("QUIT")) { break; } } networkStream.Close(); }
public Message carryOut() { MiddlewareService.Message msg = messenger.writeMessage(); Postman postman = new Postman(); return(postman.sendMessage(msg)); }