예제 #1
0
 /// <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]);
     }
 }
예제 #2
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);
     }
 }
예제 #3
0
        /// <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("");
            }
        }
예제 #4
0
        /// <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));
            }
        }