예제 #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);
 }
예제 #2
0
파일: NetworkFlow.cs 프로젝트: rene1997/ip2
        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));
 }
예제 #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;
 }
예제 #6
0
 public void sendPacket(Packet packet)
 {
     BinaryFormatter formatter = new BinaryFormatter();
     formatter.Serialize(stream, packet);
 }
예제 #7
0
 private void messageReceived(Packet packet, Connection connection)
 {
     TalkPacket response = (TalkPacket)packet;
     Console.WriteLine($"Client: Message received! {response.Message}");
 }
예제 #8
0
파일: ClientBase.cs 프로젝트: gitsly/game
 public void Send(Packet packet)
 {
     Send(packet.ToBytes());
 }
예제 #9
0
 public void sendPacket(Packet packet)
 {
     NetworkFlow.SendPacket(packet, ssl);
 }