private void messageReceived(Packet packet, Connection connection) { TalkPacket request = (TalkPacket)packet; TalkPacket response = new TalkPacket(); response.Message = "Message returning from server: " + request.Message; connection.Send(response); }
public static bool SendPacket(Packet packet, SslStream ssl) { BinaryFormatter binairyFormatter = new BinaryFormatter(); try { binairyFormatter.Serialize(ssl, packet); ssl.Flush(); } catch(Exception e) { return false; } return true; }
/// <summary> /// Sends a broadcast to all the connected udp connections. /// </summary> /// <param name="packet">The packet.</param> public void UDP_BroadCast(Packet packet) { connections.Values.ToList().ForEach(c => c.ForEach(b => b.Send(packet))); }
/// <summary> /// Sends a broadcast to all the connected tcp connections. /// </summary> /// <param name="packet">The packet.</param> public void TCP_BroadCast(Packet packet) { connections.Keys.ToList().ForEach(c => c.Send(packet)); }
/// <summary> /// Checks if the packet type matches another packet type. /// </summary> /// <param name="args">Packet arguments from event</param> /// <param name="packet">The Packet</param> /// <returns>Whether the packets have the same ID</returns> public static bool Equals(this GamePacketEventArgs args, Packet packet) { return args.GetPacketId() == packet.Id; }
public void sendPacket(Packet packet) { BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(stream, packet); }
private void messageReceived(Packet packet, Connection connection) { TalkPacket response = (TalkPacket)packet; Console.WriteLine($"Client: Message received! {response.Message}"); }
public void Send(Packet packet) { Send(packet.ToBytes()); }
public void sendPacket(Packet packet) { NetworkFlow.SendPacket(packet, ssl); }