Ejemplo n.º 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]);
     }
 }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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("");
            }
        }
Ejemplo n.º 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));
            }
        }