public void Close(EDisconnectReason eReason) { m_Peer.Flush(); m_Peer.NetManager.DisconnectPeer( m_Peer, new[] { Convert.ToByte(EDisconnectReason.ServerIsFull) }); }
/// <summary> /// Assembles the received request and sends back information to the client. /// </summary> /// <param name="mnemonics">The assembly code to be assembled.</param> /// <param name="netPeer">Contains the peer client that sent the message to the server. A wrapper around a WebSocket Client.</param> private static void Assemble(string[] mnemonics, NetPeer netPeer) { // Send back empty message struct Message messageStruct = new Message() { // Client will likely ignore this anyway (but shouldn't). MessageType = (ushort)MessageTypes.Assemble }; // Try Assembly // Assemble the bytes try { messageStruct.Data = FasmNet.Assemble(mnemonics); } // Failed to Assemble // Return nop on failure. catch { messageStruct.Data = new byte[1] { 0x90 }; } // Return back. netPeer.Send(messageStruct.GetBytes(), SendOptions.ReliableOrdered); netPeer.Flush(); }
public void SendPacket(Packet packet) { if (peer.ConnectionState == ConnectionState.Connected) { peer.Send(netPacketProcessor.Write(packet.ToWrapperPacket()), NitroxDeliveryMethod.ToLiteNetLib(packet.DeliveryMethod)); peer.Flush(); } else { Log.Info("Cannot send packet to a closed connection."); } }
public void SendPacket <T>(T packet, DeliveryMethod deliveryMethod = DeliveryMethod.ReliableOrdered) where T : class, new() { if (peer.ConnectionState == ConnectionState.Connected) { peer.Send(packetProcessor.Write(packet), deliveryMethod); peer.Flush(); } else { Console.WriteLine($"Cannot send packet {packet?.GetType()} to a closed connection {peer?.EndPoint}"); } }
public void Flush() { _peer.Flush(); }