/// <summary> /// Send the data in a byte array to the server. /// Expects a delegate to be assigned to ProcessBytesMethod which will handle the data. /// </summary> /// <param name="reloadedSocket">The individual reloadedSocket object connected to either a host or client.</param> /// <param name="message">The message that is to be sent to the server.</param> /// <param name="awaitResponse">Set true to wait for a response from the server, else false.</param> /// <param name="receiveDataDelegate">The method to call to process the received data from the server/client.</param> public static void SendData(this ReloadedSocket reloadedSocket, Message.MessageStruct message, bool awaitResponse, ProcessBytesDelegate receiveDataDelegate) { // Call the other overload and get our data back. Message.MessageStruct messageLocal = SendData(reloadedSocket, message, awaitResponse); // If we want a response from the client, receive it, copy to a buffer array and send it back to the method delegate linked to the method we want to process the outcome with. if (awaitResponse) { receiveDataDelegate(messageLocal, reloadedSocket); } }
/// <summary> /// Waits for data to be received from the websocket host. /// Can be used to wait for a response from the server in question. /// </summary> /// <param name="reloadedSocket">The individual reloadedSocket object connected to either a host or client.</param> /// <param name="receiveDataDelegate">The method to call to process the received data from the server/client.</param> public static void ReceiveData(this ReloadedSocket reloadedSocket, ProcessBytesDelegate receiveDataDelegate) { // ReceiveData using the other overload, but instead of passing // the result back, call the receive data delegate. receiveDataDelegate(ReceiveData(reloadedSocket), reloadedSocket); }