/// <summary>
        /// Begin open of stream, this provides the connection string for the
        /// remote side, that is passed as part of the open request.
        /// </summary>
        /// <param name="ct"></param>
        /// <returns></returns>
        public async Task <OpenRequest> BeginOpenAsync(CancellationToken ct)
        {
            try {
#if DEBUG_MESSAGE_CONTENT
                var encoding = CodecId.Json;
#else
                var encoding = CodecId.Mpack;
#endif
                _connection = await _socket.Provider.StreamService.CreateConnectionAsync(
                    _streamId, RemoteId, Proxy, encoding).ConfigureAwait(false);

                var maxSize = (int)_connection.MaxBufferSize;

                CreateSendBlock(maxSize);
                CreateReceiveBlock();

                return(OpenRequest.Create(_streamId, (int)encoding,
                                          _connection.ConnectionString != null ?
                                          _connection.ConnectionString.ToString() : "", 0, _connection.IsPolled,
                                          _connection.MaxBufferSize));
            }
            catch (OperationCanceledException) {
                return(null);
            }
        }
Пример #2
0
        public ActionResult Index(string target, string action)
        {
            lock (_lock)
            {
                if (!string.IsNullOrEmpty(target))
                {
                    string method = Request.HttpMethod.ToLower();
                    //if (!string.IsNullOrEmpty(action))
                    //{
                    //    method = action.ToLower().Trim();
                    //}

                    StringBuilder urlBuilder = new StringBuilder();
                    urlBuilder.Append(MConfig.Get <String>("remoteRoot"));
                    urlBuilder.Append(MConfig.Get <string>(target.Trim().ToLower()));
                    urlBuilder.AppendFormat("userId={0}", UserInfo.UserSysNo);
                    switch (method)
                    {
                    case "get":
                    {
                        NameValueCollection keyValuePair = Request.QueryString;
                        foreach (string key in keyValuePair.Keys)
                        {
                            urlBuilder.AppendFormat("&{0}={1}", key, keyValuePair[key]);
                        }
                        break;;
                    }

                    case "post":
                    {
                        NameValueCollection keyValuePair = Request.Form;
                        foreach (string key in keyValuePair.Keys)
                        {
                            urlBuilder.AppendFormat("&{0}={1}", key, keyValuePair[key]);
                        }
                        break;
                    }
                    }

                    var proxy = OpenRequest.Create(urlBuilder.ToString(), method);
                    var resp  = proxy.GetResponse();
                    return(Content(resp.ResponseText));
                }
                return(new EmptyResult());
            }
        }