public ExtendedPacketInformation(UdpMessage msg, UdpMessageType type, string ip) { Id = Guid.NewGuid(); UdpMessageType = type; UdpMessage = msg; Ip = ip; Port = msg.ReturnPort; }
public ExtendedPacketInformation(Packet packet, UdpMessageType type, string ip) { Id = Guid.NewGuid(); UdpMessageType = type; Ip = ip; Port = packet.ReturnPort; Packet = packet; }
public IUdpMessage ReadPacket(Packet packet) { // this variable will be probably not needed :\. UdpMessageType type = (UdpMessageType)packet.ReadByte(); switch (type) { case UdpMessageType.PACKET_UDP_SERVER_RESPONSE: { PacketUdpServerResponse r = new PacketUdpServerResponse(); r.GameVersion = packet.ReadByte(); if (r.GameVersion >= 4) { byte newGrfCount = packet.ReadByte(); r.ActiveNewGrfs = new PacketUdpServerResponse.ActiveNewGrf[newGrfCount]; for (int i = 0; i < newGrfCount; ++i) { PacketUdpServerResponse.ActiveNewGrf grf = new PacketUdpServerResponse.ActiveNewGrf(); grf.GrfId = packet.ReadU32(); for (int j = 0; j < 16; ++j) { grf.Md5[j] = packet.ReadByte(); } } } r.GameDate = new OttdDate(packet.ReadU32()); r.StartDate = new OttdDate(packet.ReadU32()); r.CompaniesMax = packet.ReadByte(); r.CompaniesOn = packet.ReadByte(); r.SpectactorsMax = packet.ReadByte(); r.ServerName = packet.ReadString(); r.ServerRevision = packet.ReadString(); r.LanguageId = packet.ReadByte(); r.HasPassword = packet.ReadBool(); r.ClientsMax = packet.ReadByte(); r.ClientsOn = packet.ReadByte(); r.SpectactorsOn = packet.ReadByte(); r.MapName = packet.ReadString(); r.MapWidth = packet.ReadU16(); r.MapHeight = packet.ReadU16(); r.MapSet = packet.ReadByte(); r.IsDedicated = packet.ReadBool(); return(r); } default: throw new NotImplementedException(type.ToString()); } }
private void SendMessage(UdpMessageType message, ISServerSocket client) { if (client.UdpAddress == null) { return; } udpSocket.SendTo(new byte[] { (byte)message }, client.UdpAddress); }
public void SendUdpMessage(UdpMessage msg, UdpMessageType type, string ip, int port) { var sendMsg = new SenderMessage { Body = MessagePackSerializer.Serialize(msg), Type = type }; _sender.SendMsg(sendMsg, ip, port); }
private void AddUdpMessage(UdpMessageType type, bool flag) { switch (type) { case UdpMessageType.DISCOVER_PING: if (flag) { DiscoverInPing.Add(); } else { DiscoverOutPing.Add(); } break; case UdpMessageType.DISCOVER_PONG: if (flag) { DiscoverInPong.Add(); } else { DiscoverOutPong.Add(); } break; case UdpMessageType.DISCOVER_FIND_NODE: if (flag) { DiscoverInFindNode.Add(); } else { DiscoverOutFindNode.Add(); } break; case UdpMessageType.DISCOVER_NEIGHBORS: if (flag) { DiscoverInNeighbours.Add(); } else { DiscoverOutNeighbours.Add(); } break; default: break; } }
private void HandleDatagram(UdpMessageType type, byte[] data, IPEndPoint senderAddress) { var sender = clientMan.GetClientFromUdpAddress(senderAddress); if (sender == null) { ISLogger.Write("ISUdpServer: Ignoring UDP packet from unknown address {0}", senderAddress); return; } if (type == UdpMessageType.ClientOK) { HandleClientOK(sender); } }
public void SetUdpMessageType(UdpMessageType type) { UdpMessageType = type; }
public void AddUdpOutMessage(UdpMessageType type) { AddUdpMessage(type, false); }
public void AddUdpInMessage(UdpMessageType type) { AddUdpMessage(type, true); }
public Message(UdpMessageType type, byte[] data) { this.type = type; this.data = data; }