public void Send(BasePacket packetToSend) { try { if (socket == null) { Debug.Log("sockt is null/missing"); } socket.BeginSend(packetToSend.GetPacketBytes(), 0, packetToSend.GetPacketBytes().Length, 0, new AsyncCallback(SendCallBack), socket); } catch { Debug.Log("should boot back to login menu"); //boot back to login menu } }
public byte[] GetNextPacketInQueue() { if (!SocketConnected(socket)) { return(null); } while (sendPacketQueue.Count > 0) { BasePacket packet = sendPacketQueue.Dequeue(); byte[] packetBytes = packet.GetPacketBytes(); byte[] buffer = new byte[0xffff]; Array.Copy(packetBytes, buffer, packetBytes.Length); return(buffer); } throw new Exception("Something happened in getting queued packet"); }
public void FlushQueuedSendPackets() { if (!socket.Connected) { return; } while (SendPacketQueue.Count > 0) { BasePacket packet = SendPacketQueue.Take(); byte[] packetBytes = packet.GetPacketBytes(); byte[] buffer = new byte[0xffff]; Array.Copy(packetBytes, buffer, packetBytes.Length); try { socket.Send(packetBytes); } catch (Exception e) { Program.Log.Error("Weird case, socket was d/ced: {0}", e); } } }
public void FlushQueuedSendPackets(BasePacketConnectionTypes header = BasePacketConnectionTypes.Zone) { if (!socket.Connected) { return; } while (sendPacketQueue.Count > 0) { BasePacket packet = BasePacket.CreatePacket(sendPacketQueue, PacketProcessor.isAuthenticated, false); packet.header.connectionType = (ushort)header; try { socket.Send(packet.GetPacketBytes()); sendPacketQueue.Clear(); } catch (Exception e) { Console.WriteLine("Weird case, socket was d/ced: {0}", e); } } }
public void FlushQueuedSendPackets() { if (!socket.Connected) { return; } while (SendPacketQueue.Count > 0) { BasePacket packet = SendPacketQueue.Take(); byte[] packetBytes = packet.GetPacketBytes(); try { socket.Send(packetBytes); } catch (Exception e) { Console.WriteLine("Weird case, socket was d/ced: {0}", e); } } }