Exemplo n.º 1
0
        /// <summary>Erstellt einen neuen WebRequest</summary>
        public T createRequest <T>() where T : baseRequest
        {
            baseRequest instance = Activator.CreateInstance <T>();

            instance.Session = _session;

            if (_session.currentProject.updateLogUser.Verified)
            {
                instance.serverUrl = _session.currentProject.updateLogUser.serverUrl;
            }

            return((T)instance);
        }
Exemplo n.º 2
0
    private void ReceiveCallback(IAsyncResult AR)
    {
        try
        {
            Socket socket   = (Socket)AR.AsyncState;
            int    received = socket.EndReceive(AR);

            byte[] copy = _buffer;
            Array.Resize(ref copy, received);

            baseRequest response = JsonMapper.ToObject <baseRequest>(Encoding.ASCII.GetString(copy));
            Debug.Log(response.className);

            System.Object initializedClass = initializeClass(response.className, Encoding.ASCII.GetString(copy));
            socket.BeginReceive(_buffer, 0, _buffer.Length, SocketFlags.None, new AsyncCallback(ReceiveCallback), socket);
        } catch (Exception ex) {
            Debug.Log("User disconnected accidentally. ");
            Debug.Log(ex.Message);
        }
    }