/// <summary> /// Send data (IEasyTcpPacket) to connected clients /// </summary> /// <param name="server"></param> /// <param name="data">data to send to connected clients</param> /// <param name="compression">compress data using GZIP if set to true</param> public static void SendAll(this EasyTcpServer server, IEasyTcpPacket data, bool compression = false) => server.SendAll(data.Data, compression);
/// <summary> /// Send action (IEasyTcpPacket) to connected clients /// </summary> /// <param name="server"></param> /// <param name="action">action code as string</param> /// <param name="data">data to send to connected clients</param> /// <param name="compression">compress data using GZIP if set to true</param> public static void SendAllAction(this EasyTcpServer server, string action, IEasyTcpPacket data, bool compression = false) => server.SendAllAction(action.ToActionCode(), data.Data, compression);
/// <summary> /// Send data (IEasyTcpPacket) to remote host. Then wait and return the reply /// </summary> /// <param name="client"></param> /// <param name="data">data to send to remote host</param> /// <param name="timeout">maximum time to wait for a reply, if time expired this function returns null</param> /// <param name="compression">compress data using GZIP if set to true</param> /// <returns>received reply</returns> public static Message SendAndGetReply(this EasyTcpClient client, IEasyTcpPacket data, TimeSpan?timeout = null, bool compression = false) => client.SendAndGetReply(data.Data, timeout, compression);
/// <summary> /// Send action (IEasyTcpPacket) to remote host. Then wait and return the reply /// </summary> /// <param name="client"></param> /// <param name="action">action code as string</param> /// <param name="data">data to send to remote host</param> /// <param name="timeout">maximum time to wait for a reply, if time expired this function returns null</param> /// <param name="compression">compress data using GZIP if set to true</param> /// <returns>received reply</returns> public static Message SendActionAndGetReply(this EasyTcpClient client, string action, IEasyTcpPacket data, TimeSpan?timeout = null, bool compression = false) => client.SendActionAndGetReply(action.ToActionCode(), data.Data, timeout, compression);
/// <summary> /// Send action (IEasyTcpPacket) to connected clients /// </summary> /// <param name="server"></param> /// <param name="action">action code</param> /// <param name="data">data to send to connected clients</param> /// <param name="compression">compress data using GZIP if set to true</param> public static void SendAllAction(this EasyTcpServer server, int action, IEasyTcpPacket data, bool compression = false) => server.SendAllAction(action, data.Data, compression);
/// <summary> /// Send action (IEasyTcpPacket) to remote host /// </summary> /// <param name="client"></param> /// <param name="action">action code as string</param> /// <param name="data">data to send to remote host</param> /// <param name="compression">compress data using GZIP if set to true</param> public static void SendAction(this EasyTcpClient client, string action, IEasyTcpPacket data, bool compression = false) => client.SendAction(action.ToActionCode(), data.Data, compression);
/// <summary> /// Send action (IEasyTcpPacket) to remote host /// </summary> /// <param name="client"></param> /// <param name="action">action code</param> /// <param name="data">data to send to remote host</param> /// <param name="compression">compress data using GZIP if set to true</param> public static void SendAction(this EasyTcpClient client, int action, IEasyTcpPacket data, bool compression = false) => client.SendAction(action, data.Data, compression);
/// <summary> /// Send data (IEasyTcpPacket) to remote host. Then wait and return the reply /// </summary> /// <param name="client"></param> /// <param name="data">data to send to remote host</param> /// <param name="timeout">maximum time to wait for a reply, if time expired this function returns null</param> /// <param name="compression">compress data using GZIP if set to true</param> /// <returns>received data or null</returns> public static async Task <Message> SendAndGetReplyAsync(this EasyTcpClient client, IEasyTcpPacket data, TimeSpan?timeout = null, bool compression = false) => await client.SendAndGetReplyAsync(data.Data, timeout, compression);
/// <summary> /// Determines whether the receive data is compressed with GZIP /// </summary> /// <returns>true if compressed</returns> public static bool IsCompressed(this IEasyTcpPacket packet) => IsCompressed(packet.Data);
/// <summary> /// Send data (IEasyTcpPacket) to the remote host /// </summary> /// <param name="client"></param> /// <param name="data">data to send to server</param> /// <param name="compression">compress data using GZIP if set to true</param> public static void Send(this EasyTcpClient client, IEasyTcpPacket data, bool compression = false) => client.Send(data.Data, compression);