コード例 #1
0
ファイル: Requester.cs プロジェクト: BogusCurry/arribasim-dev
        public static void MakeRequest(string requestUrl, string data,
                ReplyDelegate action)
        {
            ServicePointManagerTimeoutSupport.ResetHosts();
            WebRequest request = WebRequest.Create(requestUrl);

            request.Method = "POST";

            request.ContentType = "application/x-www-form-urlencoded";

            byte[] buffer = Encoding.ASCII.GetBytes(data);
            int length = (int) buffer.Length;
            request.ContentLength = length;

            request.BeginGetRequestStream(delegate(IAsyncResult res)
            {
                Stream requestStream = request.EndGetRequestStream(res);

                requestStream.Write(buffer, 0, length);

                request.BeginGetResponse(delegate(IAsyncResult ar)
                {
                    string reply = String.Empty;

                    using (WebResponse response = request.EndGetResponse(ar))
                    {
                        try
                        {
                            using (Stream s = response.GetResponseStream())
                                using (StreamReader r = new StreamReader(s))
                                    reply = r.ReadToEnd();

                        }
                        catch (System.InvalidOperationException)
                        {
                        }
                    }

                    action(requestUrl, data, reply);
                }, null);
            }, null);
        }
コード例 #2
0
ファイル: Requester.cs プロジェクト: BackupTheBerlios/seleon
        public static void MakeRequest(string requestUrl, string data,
                ReplyDelegate action)
        {
            WebRequest request = WebRequest.Create(requestUrl);
            WebResponse response = null;

            request.Method = "POST";

            request.ContentType = "application/x-www-form-urlencoded";

            byte[] buffer = new System.Text.ASCIIEncoding().GetBytes(data);
            int length = (int) buffer.Length;
            request.ContentLength = length;

            request.BeginGetRequestStream(delegate(IAsyncResult res)
            {
                Stream requestStream = request.EndGetRequestStream(res);

                requestStream.Write(buffer, 0, length);

                request.BeginGetResponse(delegate(IAsyncResult ar)
                {
                    string reply = String.Empty;

                    response = request.EndGetResponse(ar);

                    try
                    {
                        StreamReader r = new StreamReader(response.GetResponseStream());
                        reply = r.ReadToEnd();

                    }
                    catch (System.InvalidOperationException)
                    {
                    }

                    action(requestUrl, data, reply);
                }, null);
            }, null);
        }
コード例 #3
0
ファイル: StatHat.cs プロジェクト: chantsunman/BCFier
 public FormPoster(string base_url, string rel_url, Dictionary<string, string> parameters)
 {
   this.BaseUrl = base_url;
   this.Parameters = parameters;
   this.Reply = new ReplyDelegate((rep) => { });
   this.RelUrl = rel_url;
   this.PostForm();
 }
コード例 #4
0
ファイル: StatHat.cs プロジェクト: chantsunman/BCFier
 /// <summary>
 /// Posts a counter increment to stathat over HTTP using ez API - the stat and/or you don't have to be pre-registered
 /// </summary>
 /// <param name="ezkey">your ezkey (defaults to email address).  If you already have a stathat account, use the one associated with it.</param>
 /// <param name="stat">the name for your stat</param>
 /// <param name="count">the number</param>
 /// <param name="replyDelegate">the function you'd like called with the reply from stathat's server</param>
 public static void EzValue(string ezkey, string stat, int value, ReplyDelegate replyDelegate)
 {
   Post.EzValue(ezkey, stat, (float)value, replyDelegate);
 }
コード例 #5
0
ファイル: StatHat.cs プロジェクト: chantsunman/BCFier
 /// <summary>
 /// Posts a counter increment to stathat over HTTP using ez API - the stat and/or you don't have to be pre-registered
 /// </summary>
 /// <param name="ezkey">your ezkey (defaults to email address).  If you already have a stathat account, use the one associated with it.</param>
 /// <param name="stat">the name for your stat</param>
 /// <param name="count">the number</param>
 /// <param name="replyDelegate">the function you'd like called with the reply from stathat's server</param>
 public static void EzValue(string ezkey, string stat, float value, ReplyDelegate replyDelegate)
 {
   Dictionary<string, string> p = new Dictionary<string, string>();
   p.Add("ezkey", ezkey);
   p.Add("stat", stat);
   p.Add("value", value.ToString());
   new FormPoster(Post.BaseUrl, "/ez", p, replyDelegate);
 }
コード例 #6
0
ファイル: StatHat.cs プロジェクト: chantsunman/BCFier
 /// <summary>
 /// Posts a counter increment to stathat over HTTP using ez API - the stat and/or you don't have to be pre-registered
 /// </summary>
 /// <param name="ezkey">your ezkey (defaults to email address).  If you already have a stathat account, use the one associated with it.</param>
 /// <param name="stat">the name for your stat</param>
 /// <param name="count">the number to increment</param>
 /// <param name="replyDelegate">the function you'd like called with the reply from stathat's server</param>
 public static void EzCounter(string ezkey, string stat, int count, ReplyDelegate replyDelegate)
 {
   Post.EzCounter(ezkey, stat, (float)count, replyDelegate);
 }
コード例 #7
0
ファイル: StatHat.cs プロジェクト: chantsunman/BCFier
 /// <summary>
 /// Posts a counter increment to stathat over HTTP using ez API - the stat and/or you don't have to be pre-registered
 /// </summary>
 /// <param name="ezkey">your ezkey (defaults to email address).  If you already have a stathat account, use the one associated with it.</param>
 /// <param name="stat">the name for your stat</param>
 /// <param name="count">the number to increment</param>
 /// <param name="replyDelegate">the function you'd like called with the reply from stathat's server</param>
 public static void EzCounter(string ezkey, string stat, float count, ReplyDelegate replyDelegate)
 {
   Dictionary<string, string> p = new Dictionary<string, string>();
   p.Add("ezkey", ezkey);
   p.Add("stat", stat);
   p.Add("count", count.ToString());
   new FormPoster(Post.BaseUrl, "/ez", p, replyDelegate);
 }
コード例 #8
0
ファイル: StatHat.cs プロジェクト: chantsunman/BCFier
 /// <summary>
 /// Posts a value to stathat over HTTP
 /// </summary>
 /// <param name="key">the stat's posting key</param>
 /// <param name="ukey">your user key</param>
 /// <param name="value">the number</param>
 /// <param name="replyDelegate">the function you'd like called with the reply from stathat's server</param>
 public static void Value(string key, string ukey, int value, ReplyDelegate replyDelegate)
 {
   Post.Value(key, ukey, (float)value, replyDelegate);
 }
コード例 #9
0
ファイル: StatHat.cs プロジェクト: chantsunman/BCFier
 /// <summary>
 /// Posts a value to stathat over HTTP
 /// </summary>
 /// <param name="key">the stat's posting key</param>
 /// <param name="ukey">your user key</param>
 /// <param name="value">the number</param>
 /// <param name="replyDelegate">the function you'd like called with the reply from stathat's server</param>
 public static void Value(string key, string ukey, float value, ReplyDelegate replyDelegate)
 {
   Dictionary<string, string> p = new Dictionary<string, string>();
   p.Add("key", key);
   p.Add("ukey", ukey);
   p.Add("value", value.ToString());
   new FormPoster(Post.BaseUrl, "/v", p, replyDelegate);
 }
コード例 #10
0
ファイル: StatHat.cs プロジェクト: chantsunman/BCFier
    /// <summary>
    /// Posts a counter increment to stathat over HTTP
    /// </summary>
    /// <param name="key">the stat's posting key</param>
    /// <param name="ukey">your user key</param>
    /// <param name="count">the number to increment</param>
    /// <param name="replyDelegate">the function you'd like called with the reply from stathat's server</param>
    public static void Counter(string key, string ukey, int count, ReplyDelegate replyDelegate)
    {
      Post.Counter(key, ukey, (float)count, replyDelegate);

    }
コード例 #11
0
ファイル: StatHat.cs プロジェクト: chantsunman/BCFier
 /// <summary>
 /// Posts a counter increment to stathat over HTTP
 /// </summary>
 /// <param name="key">the stat's posting key</param>
 /// <param name="ukey">your user key</param>
 /// <param name="count">the number to increment</param>
 /// <param name="replyDelegate">the function you'd like called with the reply from stathat's server</param>
 public static void Counter(string key, string ukey, float count, ReplyDelegate replyDelegate)
 {
   Dictionary<string, string> p = new Dictionary<string, string>();
   p.Add("key", key);
   p.Add("ukey", ukey);
   p.Add("count", count.ToString());
   new FormPoster(Post.BaseUrl, "/c", p, replyDelegate);
 }
コード例 #12
0
ファイル: NXTProtocol.cs プロジェクト: acj4/nxt-ucontrol
        public NXTCommand(byte[] c, byte[] r, ReplyDelegate del = null)
        {
            command = c;// new byte[c.Length];
            reply = r;// new byte[r.Length];

            commandType = command[0];
            commandCode = command[1];

            replyDelegate = del;
            ///Array.Copy(c, this.command, c.Length);
            //Array.Copy(r, this.reply, r.Length);
        }