Exemple #1
0
        private void SendParams(int id, NetworkStream ns, Dictionary <string, string> env)
        {
            if (env == null)
            {
                this.SendRecord(id, ns, RecordType.Params, null, 0, 0);
            }
            else
            {
                MemoryStream stream = new MemoryStream();

                foreach (var param in env)
                {
                    if (String.IsNullOrEmpty(param.Value))
                    {
                        continue;
                    }

                    NameValuePair paramBody = new NameValuePair()
                    {
                        Name  = param.Key,
                        Value = param.Value
                    };

                    stream.Write(paramBody.GetHeader(), 0, 8);
                    stream.Write(Encoding.ASCII.GetBytes(param.Key), 0, param.Key.Length);
                    stream.Write(Encoding.ASCII.GetBytes(param.Value), 0, param.Value.Length);
                }

                byte[] bytes = stream.ToArray();
                this.SendRecord(id, ns, RecordType.Params, bytes, 0, bytes.Length);
                this.SendRecord(id, ns, RecordType.Params);
            }
        }