/// <summary> /// Receive /// </summary> /// <param name="toSend"></param> /// <returns></returns> private static byte[] ReceiveFromServerBytes(byte[] toSend) { if (CrossConnectivity.Current.IsConnected) { byte[] data = ServerConnector.SendByteArray(toSend); return(data); } else { return(new byte[0]); } }
/// <summary> /// Receive an OperationReturnMessage from the server after sending a server request. /// </summary> /// <param name="toSend">The data to send to server.</param> /// <returns>The OperationReturnMessage returned by the server after data has been received /// and processed by the server.</returns> private static OperationReturnMessage ReceiveFromServerORM(byte[] toSend) { if (CrossConnectivity.Current.IsConnected) { byte[] data = ServerConnector.SendByteArray(toSend); if (data.Length > 0) { OperationReturnMessage message = (OperationReturnMessage)(data[0]); return(message); } else { return(OperationReturnMessage.FalseFailedConnection); } } else { return(OperationReturnMessage.FalseNoConnection); } }
/// <summary> /// Receive string data from the server after sending a server request. /// </summary> /// <param name="toSend">The data to send to server.</param> /// <returns>The string the server returns.</returns> private static string ReceiveFromServerStringData(byte[] toSend) { if (CrossConnectivity.Current.IsConnected) { byte[] data = ServerConnector.SendByteArray(toSend); if (data.Length > 0) { string dataString = Encoding.Unicode.GetString(data); dataString = dataString.Trim(); return(dataString); } else { return(null); } } else { return(""); } }
/// <summary> /// Receive list of string arrays from the server after sending a server request. /// </summary> /// <param name="toSend">The data to send to server.</param> /// <returns>The list of string arrays the server returns.</returns> private static List <string[]> ReceiveFromServerListOfStringArrays(byte[] toSend) { if (CrossConnectivity.Current.IsConnected) { byte[] data = ServerConnector.SendByteArray(toSend); if (data.Length > 0) { BinaryFormatter binaryFormatter = new BinaryFormatter(); MemoryStream memStream = new MemoryStream(); memStream.Write(data, 0, data.Length); memStream.Position = 0; return(binaryFormatter.Deserialize(memStream) as List <string[]>); } else { return(new List <string[]>(0)); } } else { return(new List <string[]>(0)); } }