コード例 #1
0
ファイル: RequestProcessor.cs プロジェクト: mujiansu/Lync
 internal void AddPendingRequest(requestType request, ProcessRequestAsyncResult requestAsyncResult)
 {
     lock (_pendingRequests)
     {
         _pendingRequests.Add(request.requestId, requestAsyncResult);
     }
 }
コード例 #2
0
        // Private web request function, performs GET or POST calls, returns downloaded string value
        private async static Task <string> request(requestType type, string host, List <KeyValuePair <string, string> > args = null, bool utf8 = true)
        {
            switch (type)
            {
            case requestType.GET:
                string url = "";
                if (args != null)
                {
                    foreach (KeyValuePair <string, string> arg in args)
                    {
                        if (url == "")
                        {
                            url = string.Format("?{0}={1}", arg.Key, arg.Value);
                        }
                        else
                        {
                            url = string.Format("{0}&{1}={2}", url, arg.Key, arg.Value);
                        }
                    }
                }
                url = host + url;
                return(await get(url, utf8));

            case requestType.POST:
                return(await post(host, args, utf8));

            default:
                return(null);
            }
        }
コード例 #3
0
        public static async Task HandleRequestAsync(HttpListenerContext context)
        {
            var request  = context.Request;
            var response = context.Response;

            Log.Information("Got new request {requestUrl}", request.Url);
            Log.Information("Raw URL: {requestRawUrl}", request.RawUrl);
            Log.Information("request.ContentType: {requestContentType}", request.ContentType);

            var requestTypeTranslation = new Dictionary <string, requestType>
            {
                { "/scan", requestType.SCAN }
            };

            requestType type = requestTypeTranslation[request.RawUrl];

            switch (type)
            {
            case requestType.SCAN:
                ScanRequest(request, response);
                break;

            default:
                Log.Information("No valid request type");
                break;
            }
            Log.Information("Done Handling Request {requestUrl}", request.Url);
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: josudoey/RTSPExample
 public void setup()
 {
     act  = requestType.setup;
     Csep = 1;
     this.start();
     tc.ConnectSocket(_host, _port);
 }
コード例 #5
0
        internal JToken Query(requestType method, string query)
        {
            HttpWebResponse response = null;

            response = MakeRequest(NewRequest(method, Host + query));
            JToken result = ParseResult(response, query);

            return(result);
        }
コード例 #6
0
        /// <summary>
        /// Make a request without a body.
        /// </summary>
        internal HttpWebRequest NewRequest(requestType method, string uri)
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);

            request.AutomaticDecompression = DecompressionMethods.GZip;
            request        = SetLoginDetails(request);
            request.Method = method.ToString();
            request.Accept = "application/vnd.api+json";//application/json
            return(request);
        }
コード例 #7
0
        public ContextChannelRequest(requestType request,
                                     ContextChannelRequestType requestType,
                                     ConversationContextChannel channel)
        {
            Debug.Assert(request != null);
            Debug.Assert(channel != null);

            m_request     = request;
            m_channel     = channel;
            m_requestType = requestType;
        }
コード例 #8
0
ファイル: RequestProcessor.cs プロジェクト: mujiansu/Lync
        internal void RemovePendingRequest(requestType request)
        {
            lock (_pendingRequests)
            {
                ProcessRequestAsyncResult pendingRequest;

                if (_pendingRequests.TryGetValue(request.requestId, out pendingRequest))
                {
                    _pendingRequests.Remove(request.requestId);
                }
            }
        }
コード例 #9
0
        private void ProcessRequest(requestType request)
        {
            Debug.Assert(request != null);

            ContextChannelRequestReceivedEventArgs eventArgs = null;
            ContextChannelRequest contextChannelRequest      = null;

            MonitoringChannel mChannel = m_monitoringChannel;

            if (!string.IsNullOrEmpty(request.sessionId) &&
                mChannel != null &&
                mChannel.Id.Equals(request.sessionId, StringComparison.OrdinalIgnoreCase))
            {
                mChannel.ProcessRequest(request);
            }
            else
            {
                if (request.startmonitoringsession != null)
                {
                    m_monitoringChannel = new MonitoringChannel(request.startmonitoringsession.sessionId,
                                                                new Uri(request.startmonitoringsession.uri), this);

                    contextChannelRequest = new MonitoringRequest(request, ContextChannelRequestType.StartMonitoring, m_monitoringChannel);
                }
                else if (request.terminatemonitoringsession != null)
                {
                    MonitoringChannel monitoringChannel = m_monitoringChannel;

                    if (monitoringChannel != null &&
                        String.Equals(request.terminatemonitoringsession.sessionId, monitoringChannel.Id, StringComparison.OrdinalIgnoreCase))
                    {
                        contextChannelRequest = new MonitoringRequest(request, ContextChannelRequestType.StopMonitoring, monitoringChannel);
                    }
                }
                else
                {
                    //TODO:Log and ignore
                }

                if (contextChannelRequest != null)
                {
                    eventArgs = new ContextChannelRequestReceivedEventArgs(contextChannelRequest.RequestType, contextChannelRequest);

                    EventHandler <ContextChannelRequestReceivedEventArgs> eventHandler = this.RequestReceived;
                    if (eventHandler != null)
                    {
                        eventHandler.Invoke(this, eventArgs);
                    }
                }
            }
        }
コード例 #10
0
        public ConnectMaster(requestType request, String name, String mapname, ModeMulti mode)
        {
            serversConnected = new List <ServerInfo>();

            config = new NetPeerConfiguration("TDZmaster");
            client = new NetClient(config);
            client.Start();

            NetOutgoingMessage requestSrv = client.CreateMessage();

            requestSrv.Write((Int32)request);

            if (request == requestType.create)
            {
                requestSrv.Write(name);
                String tmp = mapname.Replace(Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "/TDZ/Map/Multi/", "");
                requestSrv.Write(tmp);
                requestSrv.Write((Int32)mode);
            }

            client.Connect(MasterIPAdress, 4242, requestSrv);
            Thread.Sleep(1000);

            NetIncomingMessage incMsg;
            bool haveDatas = false;

            while (!haveDatas)
            {
                incMsg = client.ReadMessage();
                if (incMsg != null && incMsg.MessageType == NetIncomingMessageType.Data)
                {
                    if (request == requestType.create)
                    {
                        serverCreated = new ServerInfo(name, mapname, incMsg.ReadInt32(), 0, mode);
                    }
                    else
                    {
                        int count = incMsg.ReadInt32();
                        for (int i = 0; i < count; i++)
                        {
                            serversConnected.Add(new ServerInfo(incMsg.ReadString(), incMsg.ReadString(), incMsg.ReadInt32(), incMsg.ReadInt32(), (ModeMulti)incMsg.ReadInt32()));
                        }
                    }
                    haveDatas = true;
                    client.Recycle(incMsg);
                }
            }
        }
コード例 #11
0
ファイル: RequestProcessor.cs プロジェクト: mujiansu/Lync
        private static requestType CreateRequest(int requestId, string sessionId,
                                                 ContextChannelRequestType requestType)
        {
            requestType request = new requestType
            {
                requestId = (uint)requestId,
                sessionId = sessionId
            };

            switch (requestType)
            {
            case ContextChannelRequestType.Hold:
                request.hold = new object();
                break;

            case ContextChannelRequestType.Escalate:
                break;

            case ContextChannelRequestType.Retrieve:
                request.retrieve = new object();
                break;

            case ContextChannelRequestType.StartMonitoring:
                break;

            case ContextChannelRequestType.StopMonitoring:
                break;

            case ContextChannelRequestType.Whisper:
                break;

            case ContextChannelRequestType.BargeIn:
                request.bargein = new object();
                break;

            default:
                Debug.Assert(false, "invalid request type");
                break;
            }

            return(request);
        }
コード例 #12
0
    bool createWebRequest(requestType rt, string webService)
    {
        try {
            if (rt == requestType.GENERIC)
            {
                request = WebRequest.Create(serverUrl + webService);
            }
            else             //(rt == requestType.PING)
            {
                requestPing = WebRequest.Create(serverUrl + webService);
            }
        } catch {
            this.ResultMessage =
                string.Format(Catalog.GetString("You are not connected to the Internet\nor {0} server is down."),
                              serverUrl) + "\n\nMaybe proxy is not configured";
            //System.Net.WebRequest.GetSystemWebProxy System.NullReferenceException: Object reference not set to an instance of an object
            return(false);
        }

        return(true);
    }
コード例 #13
0
        /// <summary>
        /// Add a body to a request.
        /// </summary>
        internal HttpWebRequest NewRequest(requestType method, string uri, string body)
        {
            HttpWebRequest request = NewRequest(method, uri);

            request.AutomaticDecompression = DecompressionMethods.GZip;
            request.ContentType            = "application/json";
            request.ContentLength          = body.Length;

            try
            {
                using (var streamWriter = new StreamWriter(request.GetRequestStream()))
                {
                    streamWriter.Write(body);
                    streamWriter.Flush();
                }
            }
            catch (WebException ex)
            {
                throw ex;
            }
            return(request);
        }
コード例 #14
0
 private void InnerChannel_DataReceived(object sender, ConversationContextChannelDataReceivedEventArgs e)
 {
     try
     {
         if (e.ContentDescription != null)
         {
             if (e.ContentDescription.ContentType.ToString().Equals(WireHelpers.Request, StringComparison.OrdinalIgnoreCase))
             {
                 requestType request = WireHelpers.ParseMessageBody <requestType>(e.ContentDescription.GetBody());
                 this.ProcessRequest(request);
             }
             else
             {
                 //TODO:Log and ignore
             }
         }
     }
     catch (Exception)
     {
         //TODO: Log and ignore
     }
 }
コード例 #15
0
        internal void ProcessRequest(requestType request)
        {
            Debug.Assert(request != null);

            ContextChannelRequestReceivedEventArgs eventArgs = null;
            ContextChannelRequest contextChannelRequest      = null;

            if (request.bargein != null)
            {
                contextChannelRequest = new ContextChannelRequest(request,
                                                                  ContextChannelRequestType.BargeIn,
                                                                  m_supervisorChannel.InnerChannel);
            }
            else if (request.whisper != null)
            {
                contextChannelRequest = new WhisperRequest(request,
                                                           m_supervisorChannel.InnerChannel);
            }
            //else if (request.terminatemonitoringsession != null)
            //{
            //    contextChannelRequest = new ContextChannelRequest(request,
            //        ContextChannelRequestType.Hold,
            //        m_innerChannel);
            //}
            else
            {
                //TODO:Log and ignore
            }

            eventArgs = new ContextChannelRequestReceivedEventArgs(contextChannelRequest.RequestType, contextChannelRequest);

            EventHandler <ContextChannelRequestReceivedEventArgs> eventHandler = this.RequestReceived;

            if (eventHandler != null)
            {
                eventHandler.Invoke(this, eventArgs);
            }
        }
コード例 #16
0
        private void ProcessRequest(requestType request)
        {
            Debug.Assert(request != null);

            ContextChannelRequestReceivedEventArgs eventArgs = null;
            ContextChannelRequest contextChannelRequest      = null;

            if (request.hold != null)
            {
                contextChannelRequest = new ContextChannelRequest(request,
                                                                  ContextChannelRequestType.Hold,
                                                                  m_innerChannel);
            }
            else if (request.escalate != null)
            {
                contextChannelRequest = new EscalateRequest(request,
                                                            m_innerChannel);
            }
            else if (request.retrieve != null)
            {
                contextChannelRequest = new ContextChannelRequest(request,
                                                                  ContextChannelRequestType.Retrieve,
                                                                  m_innerChannel);
            }
            else
            {
                //TODO:Log and ignore
            }

            eventArgs = new ContextChannelRequestReceivedEventArgs(contextChannelRequest.RequestType, contextChannelRequest);

            EventHandler <ContextChannelRequestReceivedEventArgs> eventHandler = this.RequestReceived;

            if (eventHandler != null)
            {
                eventHandler.Invoke(this, eventArgs);
            }
        }
コード例 #17
0
ファイル: Form1.cs プロジェクト: josudoey/RTSPExample
 public void play()
 {
     act = requestType.play;
     tc.ConnectSocket(_host, _port);
 }
コード例 #18
0
ファイル: Form1.cs プロジェクト: fajoy/RTSPExample
 public void setup()
 {
     act = requestType.setup;
     Csep = 1;
     this.start();
     tc.ConnectSocket(_host, _port);
 }
コード例 #19
0
ファイル: Form1.cs プロジェクト: fajoy/RTSPExample
 public void teardown()
 {
     act = requestType.teardown;
     tc.ConnectSocket(_host, _port);
 }
コード例 #20
0
ファイル: Scorm.cs プロジェクト: PavelPZ/NetNew
 //Select
 static string getData(requestType type, pars par) {
   var db = Lib.CreateContext();
   //Where cast queryObj
   var q = getQuery(db, par);
   bool isLog = Logger.LogLowId() != null;
   string[] res;
   string[] log = null;
   //Select cast queryObj
   switch (type) {
     case requestType.get_data1: res = q.Select(s => s.Data1).ToArray(); if (isLog) log = res.Select(s => Encoding.UTF8.GetString(Convert.FromBase64String(s))).ToArray(); break; //Data1
     case requestType.get_data2: res = q.Select(s => s.Data2).ToArray(); if (isLog) log = res.Select(s => Encoding.UTF8.GetString(Convert.FromBase64String(s))).ToArray(); break; //Data1
     case requestType.get_key1str_data2: res = q.SelectMany(s => XExtension.Return(s.Key1Str, s.Data2)).ToArray(); break; //Key1Str, Data2
     case requestType.get_data1_data2: res = q.SelectMany(s => XExtension.Return(s.Data1, s.Data2)).ToArray(); if (isLog) log = res.Select(s => Encoding.UTF8.GetString(Convert.FromBase64String(s))).ToArray(); break; //Data1, Data2
     case requestType.get_key2ints_data2: res = q.Select(s => s.Data2).ToArray(); if (isLog) log = res.Select(s => Encoding.UTF8.GetString(Convert.FromBase64String(s))).ToArray(); break; //Data2
     default: throw new NotImplementedException();
   }
   if (isLog && log != null) Logger.Log(">>> GetData: " + (log.Length==0 ? "" : log.Aggregate((r, i) => r + "\r\n" + i)));
   //Vsechny hodnoty proloz oddelovacem
   StringBuilder sb = new StringBuilder();
   foreach (var s in res) { sb.Append(s); sb.Append(delim); }
   if (sb.Length > 0) sb.Length = sb.Length - 1;
   //vraceni hodnoty pro response
   return sb.ToString();
 }
コード例 #21
0
ファイル: Form1.cs プロジェクト: ECain/GeocodingAndRouting
 private void Deserialize(requestType type, string json)
 {
     JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
       if (type == requestType.authenticate)
       {
     Authentication authentication = javaScriptSerializer.Deserialize<Authentication>(json);
     _token = authentication.token;
       }
       else if (type == requestType.batchGeocode)
       {
     BatchGeocodingResponse batchGeocodingResponse = javaScriptSerializer.Deserialize<BatchGeocodingResponse>(json);
       }
       else if (type == requestType.geocode)
       {
     Geocode geocode = javaScriptSerializer.Deserialize<Geocode>(json);
       }
       else if (type == requestType.reverseGeocode)
       {
     ReverseGeocode reverseGeocode = javaScriptSerializer.Deserialize<ReverseGeocode>(json);
       }
       else if (type == requestType.route)
       {
     RouteDataContract route = javaScriptSerializer.Deserialize<RouteDataContract>(json);
       }
 }
コード例 #22
0
ファイル: WebCalls.cs プロジェクト: swiftyspiffy/KrakenBot2
 // Private web request function, performs GET or POST calls, returns downloaded string value
 private async static Task<string> request(requestType type, string host, List<KeyValuePair<string, string>> args = null, bool utf8 = true)
 {
     switch(type)
     {
         case requestType.GET:
             string url = "";
             if (args != null)
                 foreach (KeyValuePair<string, string> arg in args)
                     if (url == "")
                         url = string.Format("?{0}={1}", arg.Key, arg.Value);
                     else
                         url = string.Format("{0}&{1}={2}", url, arg.Key, arg.Value);
             url = host + url;
             return await get(url, utf8);
         case requestType.POST:
             return await post(host, args, utf8);
         default:
             return null;
     }
 }
コード例 #23
0
 public EscalateRequest(requestType request,
                        ConversationContextChannel channel)
     : base(request, ContextChannelRequestType.Escalate, channel)
 {
     m_skills = new List <agentSkillType>(request.escalate.agentSkills);
 }
コード例 #24
0
 /// <summary>
 /// 默认构造函数
 /// </summary>
 /// <remarks>
 /// 默认的请求方式的GET
 /// </remarks>
 public WP7HttpRequest()
 {
     _request_url = "";
     _parameter = new Dictionary<string, string>();
     _request_type = requestType.GET; //默认请求方式为GET方式
 }
コード例 #25
0
ファイル: Form1.cs プロジェクト: josudoey/RTSPExample
 public void teardown()
 {
     act = requestType.teardown;
     tc.ConnectSocket(_host, _port);
 }
コード例 #26
0
ファイル: Form1.cs プロジェクト: fajoy/RTSPExample
 public void play()
 {
     act = requestType.play;
     tc.ConnectSocket(_host, _port);
 }
コード例 #27
0
 public WhisperRequest(requestType request,
                       ConversationContextChannel channel)
     : base(request, ContextChannelRequestType.Whisper, channel)
 {
     m_uri = new Uri(request.whisper.uri);
 }
コード例 #28
0
ファイル: Form1.cs プロジェクト: josudoey/RTSPExample
 public void pause()
 {
     act = requestType.pause;
     tc.ConnectSocket(_host, _port);
 }
コード例 #29
0
 internal MonitoringRequest(requestType request, ContextChannelRequestType requestType, MonitoringChannel monitoringChannel)
     : base(request, requestType, monitoringChannel.SupervisorContextChannel.InnerChannel)
 {
     m_monitoringChannel = monitoringChannel;
 }
コード例 #30
0
ファイル: Form1.cs プロジェクト: fajoy/RTSPExample
 public void pause()
 {
     act = requestType.pause;
     tc.ConnectSocket(_host, _port);
 }