public bool Send(byte channelID, byte[] data, int offset, int length) { if (data == null) { throw new ArgumentNullException("data"); } bool ret; using (var packet = new Packet()) { packet.Create(data, offset, length); ret = Send(channelID, packet); } return ret; }
public static bool Send(this Peer peer, ChannelID channel, byte[] data, bool reliable = true, bool unsequenced = false) { var packet = new ENet.Packet(); var flags = PacketFlags.None; if (reliable) { flags |= PacketFlags.Reliable; } if (unsequenced) { flags |= PacketFlags.Unsequenced; } packet.Create(data, 0, data.Length, flags); return(peer.Send((byte)channel, packet)); }
public bool BroadcastPacket(byte[] data, Channel channelNo, PacketFlags flag = PacketFlags.Reliable) { byte[] temp; if (data.Length >= 8) { temp = _blowfish.Encrypt(data); } else { temp = data; } var packet = new ENet.Packet(); packet.Create(temp); _server.Broadcast((byte)channelNo, ref packet); return(true); }
public bool broadcastPacket(byte[] data, Channel channelNo, PacketFlags flag = PacketFlags.Reliable) { ////PDEBUG_LOG_LINE(Logging," Broadcast packet:\n"); //printPacket(data, "Broadcast: "); byte[] temp; if (data.Length >= 8) { temp = _blowfish.Encrypt(data); } else { temp = data; } var packet = new ENet.Packet(); packet.Create(temp); _server.Broadcast((byte)channelNo, ref packet); return(true); }
public bool BroadcastPacket(byte[] data, Channel channelNo, PacketFlags flag = PacketFlags.Reliable) { if (data.Length >= 8) { // send packet to all peers and save failed ones List <KeyValuePair <ulong, Peer> > failedPeers = _peers.Where(x => !x.Value.Send((byte)channelNo, _blowfishes[x.Key].Encrypt(data))).ToList(); if (failedPeers.Count() > 0) { Debug.WriteLine($"Broadcasting packet failed for {failedPeers.Count()} peers."); return(false); } return(true); } else { var packet = new ENet.Packet(); packet.Create(data); _server.Broadcast((byte)channelNo, ref packet); return(true); } }
public bool Send(byte channelID, byte[] data, int offset, int length) { if (data == null) { throw new ArgumentNullException("data"); } bool ret; using (var packet = new Packet()) { packet.Create(data, offset, length); ret = Send(channelID, packet); } return ret; }