private void butSendText_Click(object sender, EventArgs e) { if (client.IsConnected) { InternalData d = new InternalData("rawtext", "", Encoding.ASCII.GetBytes(txtInput.Text)); client.Send(d); } }
public void SendColor(int color) { using (MemoryStream memoryStream = new MemoryStream(10)) using (BinaryWriter writer = new BinaryWriter(memoryStream)) { writer.Write((byte)MessageType.ClientUpdateStarted); writer.Write((byte)id); writer.Write(color); Console.WriteLine("Sending Color to: {0}", serverIP); byte[] finalBuffer = memoryStream.ToArray(); netClient.Send(finalBuffer, serverIP, NetClientMessageType.Unreliable); } }
public void CallTeardown_rsp(NetworkMessage msg, NetClient sender, bool next_domain) { msg.src = myCPCC.port; msg.dst = myCPCC.ncc_port; Disp.ViewOnScreen("Do you accept disconnection?"); string choice = Console.ReadLine(); if (choice.Equals("accept")) { msg.payload = "CALL_TEARDOWN_RSP=TRUE"; } else if (choice.Equals("refuse")) { if (next_domain) { msg.payload = "CALL_TEARDOWN_RSP=FALSE,NEXT_DOMAIN=TRUE"; } else { msg.payload = "CALL_TEARDOWN_RSP=FALSE,NEXT_DOMAIN=FALSE"; } } sender.Send(msg.ToBytes()); Disp.ViewOnScreen(msg.ToString("Message sent: ")); }
public void CallRequest_req(string src, string dst, int cap, NetClient sender) { NetworkMessage msg = new NetworkMessage(this.port, this.ncc_port, "CALL_REQUEST " + src + " " + dst + " " + cap.ToString()); sender.Send(msg.ToBytes()); Disp.ViewOnScreen(msg.ToString("Message sent: ")); stream_gen.AddCalledHost(dst); }
public void CallTeardown_req(string dst, int cap, NetClient sender) { NetworkMessage msg = new NetworkMessage(this.port, this.ncc_port, "CALL_TEARDOWN_REQ " + this.port + " " + dst + " " + cap.ToString()); sender.Send(msg.ToBytes()); Disp.ViewOnScreen(msg.ToString("Message sent: ")); stream_gen.AddCalledHost(dst); }
public void SendClientHello() { if (connectionTask != null && !connectionTask.IsCanceled && !connectionTask.IsFaulted && !connectionTask.IsCompleted) { connectionTask.Dispose(); } connectionTask = Task.Run(new Action(netClientConnection.Start)); using (MemoryStream memoryStream = new MemoryStream(256)) using (BinaryWriter writer = new BinaryWriter(memoryStream)) { writer.Write((byte)MessageType.ClientHello); Console.WriteLine("Sending SendClientHello to: {0}", serverIPConnection); byte[] finalBuffer = memoryStream.ToArray(); netClientConnection.Send(finalBuffer, serverIPConnection, NetClientMessageType.Reliable); } }