public void SetReceiver(CNSMessageClient client) { if (activeReceiver == client) { activeReceiver = null; active = !active; return; } if (activeSender == client) { activeSender = null; active = !active; return; } if (active) { activeSender = client; } else { activeReceiver = client; } active = !active; }
public void SendMessage(CNSMessageClient receiver, string message) { AddMessageReceiver(receiver); MessageSendingParams p = outgoingMessages[receiver]; string mess = p.SendMessage(message); receiver.ReceiveMessage(this, mess); }
public void AddMessageSender(CNSMessageClient other, MessageReceivingParams receivingParams) { if (incomingMessages.ContainsKey(other)) { return; } incomingMessages.Add(other, receivingParams); }
public void AddMessageReceiver(CNSMessageClient other) { if (outgoingMessages.ContainsKey(other)) { return; } MessageSendingParams p = new MessageSendingParams(); outgoingMessages.Add(other, p); other.AddMessageSender(this, new MessageReceivingParams(p.publicKey, p.encryptionKey, p.encryptionIV)); }
public void ReceiveMessage(CNSMessageClient sender, string cryptText) { MessageReceivingParams p = incomingMessages[sender]; string message; if (p.DecryptMessage(cryptText, out message)) { OnMessageRecievedCallback?.Invoke(message); CNSClientManager.WriteLine("Received a verified message at Client " + clientID + " from Client " + sender.clientID + " : " + message); } else { OnMessageFailedCallback?.Invoke(); } }
public static void RegisterClient(CNSMessageClient client) { client.GetComponent <Button>().onClick.AddListener(() => instance.SetReceiver(client)); client.clientID = clientCount; clientCount++; }