Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
        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));
 }
Exemplo n.º 5
0
 /// <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;
 }
Exemplo n.º 6
0
 public void sendPacket(Packet packet)
 {
     BinaryFormatter formatter = new BinaryFormatter();
     formatter.Serialize(stream, packet);
 }
Exemplo n.º 7
0
 private void messageReceived(Packet packet, Connection connection)
 {
     TalkPacket response = (TalkPacket)packet;
     Console.WriteLine($"Client: Message received! {response.Message}");
 }
Exemplo n.º 8
0
 public void Send(Packet packet)
 {
     Send(packet.ToBytes());
 }
Exemplo n.º 9
0
 public void sendPacket(Packet packet)
 {
     NetworkFlow.SendPacket(packet, ssl);
 }