当前位置: 首页>>代码示例>>C#>>正文


C# UruStream.Close方法代码示例

本文整理汇总了C#中MUd.UruStream.Close方法的典型用法代码示例。如果您正苦于以下问题:C# UruStream.Close方法的具体用法?C# UruStream.Close怎么用?C# UruStream.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MUd.UruStream的用法示例。


在下文中一共展示了UruStream.Close方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ToArray

        public byte[] ToArray()
        {
            MemoryStream ms = new MemoryStream();
            UruStream s = new UruStream(ms);
            Write(s);

            byte[] buf = ms.ToArray();
            s.Close();
            ms.Close();

            return buf;
        }
开发者ID:Hoikas,项目名称:mudpit,代码行数:12,代码来源:AuthManifest.cs

示例2: Connect

        public override bool Connect()
        {
            if (!base.Connect()) return false;

            //Send the FileConnectHeader
            UruStream s = new UruStream(new NetworkStream(fSocket, false));
            s.BufferWriter();
            fHeader.Write(s);
            s.WriteUInt(12); //Size
            s.WriteUInt(0);
            s.WriteUInt(0);
            s.FlushWriter();
            s.Close();

            fSocket.BeginReceive(new byte[4], 0, 4, SocketFlags.Peek, new AsyncCallback(IReceive), null);
            return true;
        }
开发者ID:Hoikas,项目名称:mudpit,代码行数:17,代码来源:FileClient.cs

示例3: Ping

        public void Ping(int time)
        {
            File_PingPong ping = new File_PingPong();
            ping.fPingTime = time;

            ResetIdleTimer();
            lock (fSocket) {
                MemoryStream ms = new MemoryStream();
                UruStream s = new UruStream(ms);

                s.WriteUInt(12);
                s.WriteInt((int)FileCli2Srv.PingRequest);
                ping.Write(s);

                fSocket.Send(ms.ToArray());

                s.Close();
                ms.Close();
            }
        }
开发者ID:Hoikas,项目名称:mudpit,代码行数:20,代码来源:FileClient.cs

示例4: Connect

        public override bool Connect()
        {
            if (!base.Connect()) return false;

            //Send the GateConnectHeader
            UruStream s = new UruStream(new NetworkStream(fSocket, false));
            s.BufferWriter();
            fHeader.Write(s);
            s.WriteInt(20);
            s.WriteBytes(Guid.Empty.ToByteArray());
            s.FlushWriter();
            s.Close();

            //Init encryption
            if (!base.NetCliConnect(4))
                return false;

            fSocket.BeginReceive(new byte[2], 0, 2, SocketFlags.Peek, new AsyncCallback(IReceive), null);
            return true;
        }
开发者ID:Hoikas,项目名称:mudpit,代码行数:20,代码来源:GateClient.cs

示例5: RequestBuildID

        public uint RequestBuildID()
        {
            File_BuildIdRequest req = new File_BuildIdRequest();
            req.fTransID = IGetTransID();

            ResetIdleTimer();
            lock (fSocket) {
                MemoryStream ms = new MemoryStream();
                UruStream s = new UruStream(ms);

                s.WriteUInt(12);
                s.WriteInt((int)FileCli2Srv.BuildIdRequest);
                req.Write(s);

                fSocket.Send(ms.ToArray());

                s.Close();
                ms.Close();
            }

            return req.fTransID;
        }
开发者ID:Hoikas,项目名称:mudpit,代码行数:22,代码来源:FileClient.cs

示例6: IReceive

        private void IReceive(IAsyncResult ar)
        {
            try {
                lock (fSocket) {
                    fSocket.EndReceive(ar);

                    ResetIdleTimer();

                    //Size
                    byte[] buf = new byte[4];
                    fSocket.Receive(buf);

                    //Message
                    buf = new byte[BitConverter.ToInt32(buf, 0) - 4];
                    fSocket.Receive(buf);
                    fStream = new UruStream(new MemoryStream(buf));

                    FileSrv2Cli msg = (FileSrv2Cli)fStream.ReadInt();
                    switch (msg) {
                        case FileSrv2Cli.BuildIdReply:
                            IGotBuildID();
                            break;
                        case FileSrv2Cli.PingReply:
                            IPong();
                            break;
                        default:
                            string test = Enum.GetName(typeof(FileSrv2Cli), msg);
                            throw new NotSupportedException(msg.ToString("X") + " - " + test);
                    }

                    fStream.Close();
                }

                fSocket.BeginReceive(new byte[2], 0, 2, SocketFlags.Peek, new AsyncCallback(IReceive), null);
            } catch (ObjectDisposedException) {
            } catch (SocketException) {
                fSocket.Close();
            #if !DEBUG
            } catch (Exception e) {
                FireException(e);
            #endif
            }
        }
开发者ID:Hoikas,项目名称:mudpit,代码行数:43,代码来源:FileClient.cs

示例7: NetCliConnect

        protected virtual bool NetCliConnect(int g)
        {
            UruStream s = new UruStream(new NetworkStream(fSocket, false));

            //NetCliConnect
            ISetupKeys(g);
            s.BufferWriter();
            s.WriteByte((byte)NetCliConnectMsg.kNetCliConnect);
            s.WriteByte(66);
            s.WriteBytes(fDhData);
            s.FlushWriter();

            //Recv NetCliEncrypt
            if (s.ReadByte() != (byte)NetCliConnectMsg.kNetCliEncrypt) { fSocket.Close(); return false; }
            byte[] seed = s.ReadBytes((int)(s.ReadByte() - 2));
            ISetupEncryption(seed);

            s.Close();
            return true;
        }
开发者ID:Hoikas,项目名称:mudpit,代码行数:20,代码来源:Cli2Srv.cs

示例8: Connect

        public override bool Connect()
        {
            if (!base.Connect()) return false;

            //Send the AuthConnectHeader
            UruStream s = new UruStream(new NetworkStream(fSocket, false));
            s.BufferWriter();
            fHeader.Write(s);
            s.WriteInt(20);
            s.WriteBytes(Guid.Empty.ToByteArray());
            s.FlushWriter();
            s.Close();

            //Init encryption
            if(!base.NetCliConnect(41))
                return false;

            //Register the client...
            //Don't require the user to do this.
            Auth_RegisterRequest req = new Auth_RegisterRequest();
            req.fBuildID = fHeader.fBuildID;

            fStream.BufferWriter();
            fStream.WriteUShort((ushort)AuthCli2Srv.ClientRegisterRequest);
            req.Write(fStream);
            fStream.FlushWriter();

            fSocket.BeginReceive(new byte[2], 0, 2, SocketFlags.Peek, new AsyncCallback(IReceive), null);
            fChgHack.Reset(); fChgHack.WaitOne();

            return true;
        }
开发者ID:Hoikas,项目名称:mudpit,代码行数:32,代码来源:AuthClient.cs

示例9: ToByteArray

        public byte[] ToByteArray()
        {
            MemoryStream ms = new MemoryStream();
            UruStream w = new UruStream(ms);

            foreach (FileManifestEntry e in fEntries) {
                //Filename
                w.WriteBytes(Encoding.Unicode.GetBytes(e.fFileName));
                w.WriteUShort((ushort)0);

                //Download
                w.WriteBytes(Encoding.Unicode.GetBytes(e.fDownloadName));
                w.WriteUShort((ushort)0);

                //Hash
                w.WriteBytes(Encoding.Unicode.GetBytes(e.fHash));
                w.WriteUShort((ushort)0);

                //Compressed Hash
                w.WriteBytes(Encoding.Unicode.GetBytes(e.fCompressedHash));
                w.WriteUShort((ushort)0);

                //File Size
                w.WriteUShort((ushort)(e.fFileSize >> 16));
                w.WriteUShort((ushort)(e.fFileSize & 0xFFFF));
                w.WriteUShort((ushort)0);

                //Compressed File Size
                w.WriteUShort((ushort)(e.fCompressedSize >> 16));
                w.WriteUShort((ushort)(e.fCompressedSize & 0xFFFF));
                w.WriteUShort((ushort)0);

                //Flags
                w.WriteUShort((ushort)(e.fFlags >> 16));
                w.WriteUShort((ushort)(e.fFlags & 0xFFFF));
                w.WriteUShort((ushort)0);
            }

            w.WriteUShort((ushort)0);

            byte[] rtn = ms.ToArray();
            w.Close();
            ms.Close();
            return rtn;
        }
开发者ID:Hoikas,项目名称:mudpit,代码行数:45,代码来源:Manifest.cs

示例10: ToArray


//.........这里部分代码省略.........
                    case Fields.kCreateAgeName:
                        s.WriteUnicodeStringV32(fCreateAgeName);
                        break;
                    case Fields.kCreateAgeUuid:
                        s.WriteBytes(fCreateAgeUuid.ToByteArray());
                        break;
                    case Fields.kCreateTime:
                        s.WriteUInt(ToUnixTime(fCreateTime));
                        break;
                    case Fields.kCreatorIdx:
                        s.WriteUInt(fCreatorIdx.Value);
                        break;
                    case Fields.kCreatorUuid:
                        s.WriteBytes(fCreatorUuid.ToByteArray());
                        break;
                    case Fields.kInt32_1:
                        s.WriteInt(fInt32[0].Value);
                        break;
                    case Fields.kInt32_2:
                        s.WriteInt(fInt32[1].Value);
                        break;
                    case Fields.kInt32_3:
                        s.WriteInt(fInt32[2].Value);
                        break;
                    case Fields.kInt32_4:
                        s.WriteInt(fInt32[3].Value);
                        break;
                    case Fields.kIString64_1:
                        s.WriteUnicodeStringV32(fIString64[0]);
                        break;
                    case Fields.kIString64_2:
                        s.WriteUnicodeStringV32(fIString64[1]);
                        break;
                    case Fields.kModifyTime:
                        s.WriteUInt(ToUnixTime(fModifyTime));
                        break;
                    case Fields.kNodeIdx:
                        s.WriteUInt(fIdx);
                        break;
                    case Fields.kNodeType:
                        s.WriteUInt((uint)fNodeType);
                        break;
                    case Fields.kString64_1:
                        s.WriteUnicodeStringV32(fString64[0]);
                        break;
                    case Fields.kString64_2:
                        s.WriteUnicodeStringV32(fString64[1]);
                        break;
                    case Fields.kString64_3:
                        s.WriteUnicodeStringV32(fString64[2]);
                        break;
                    case Fields.kString64_4:
                        s.WriteUnicodeStringV32(fString64[3]);
                        break;
                    case Fields.kString64_5:
                        s.WriteUnicodeStringV32(fString64[4]);
                        break;
                    case Fields.kString64_6:
                        s.WriteUnicodeStringV32(fString64[5]);
                        break;
                    case Fields.kText_1:
                        s.WriteUnicodeStringV32(fText[0]);
                        break;
                    case Fields.kText_2:
                        s.WriteUnicodeStringV32(fText[1]);
                        break;
                    case Fields.kUInt32_1:
                        s.WriteUInt(fUInt32[0].Value);
                        break;
                    case Fields.kUInt32_2:
                        s.WriteUInt(fUInt32[1].Value);
                        break;
                    case Fields.kUInt32_3:
                        s.WriteUInt(fUInt32[2].Value);
                        break;
                    case Fields.kUInt32_4:
                        s.WriteUInt(fUInt32[3].Value);
                        break;
                    case Fields.kUuid_1:
                        s.WriteBytes(fUuid[0].ToByteArray());
                        break;
                    case Fields.kUuid_2:
                        s.WriteBytes(fUuid[1].ToByteArray());
                        break;
                    case Fields.kUuid_3:
                        s.WriteBytes(fUuid[2].ToByteArray());
                        break;
                    case Fields.kUuid_4:
                        s.WriteBytes(fUuid[3].ToByteArray());
                        break;
                }

                bit <<= 1;
            }

            byte[] buf = ms.ToArray();
            s.Close();
            ms.Close();
            return buf;
        }
开发者ID:Hoikas,项目名称:mudpit,代码行数:101,代码来源:VaultNode.cs

示例11: Parse

        public static VaultNode Parse(byte[] data)
        {
            MemoryStream ms = new MemoryStream(data);
            UruStream s = new UruStream(ms);

            VaultNode n = new VaultNode();
            n.Read(s);

            s.Close();
            ms.Close();

            return n;
        }
开发者ID:Hoikas,项目名称:mudpit,代码行数:13,代码来源:VaultNode.cs


注:本文中的MUd.UruStream.Close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。