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


C# Msg.Write方法代码示例

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


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

示例1: OnGUI

	void OnGUI(){
		GUI.TextArea (new Rect (10, 10, 500, 400), show_str);
		modelId =GUI.TextField (new Rect (520, 10, 80, 30), modelId);
		actionId=GUI.TextField (new Rect (600, 10, 80, 30), actionId);
		msg =GUI.TextField (new Rect (520, 50, 160, 30), msg);
		if (GUI.Button (new Rect (690, 10, 160, 30), "ADD_STR")) {
			
		}
		if (GUI.Button (new Rect (690, 50, 160, 30), "SEND")) {
			string str =  modelId + "-" + actionId + " data =" + msg;

            string statc = "0,0,'538642', '1', '10002', '1', 99000000, 999999";
			Msg data = new Msg ();
			data.Write (1);
			//data.Write ('a');
			//data.Write ((byte)1.1f);
			//data.Write(11);
			data.Write (2L);


			byte[] b = data.Buffer;

			bool a0 = data.ReadBoolean ();
			//char a1 = (char)data.ReadByte ();
			long a2 = data.ReadInt64 ();
			//float a2 = float.Parse(data.ReadBytes (sizeof(float)));
			Debug.Log ("=sum length=="+(sizeof(int)+sizeof(long))+"============byte array===" + data.Length);
			Debug.Log ("=======a0=" + a0);
			//Debug.Log ("=======a1=" + a1);
			Debug.Log ("=======a2=" + a2);
			//Debug.Log ("encode code==================="+code);

            AppendShowString(str);

		}
        if (GUI.Button(new Rect(690, 90, 160, 30), "connect")) {
            try { 
                network.connectServer();
                AppendShowString("connect to server");
            }
            catch (Exception e) {
                AppendShowString(e.ToString());
            }
		}
		if (GUI.Button(new Rect(690,130,160,30),"disconnect")){
            try
            {
                network.closeConnection();
                AppendShowString("disconnect server");
            }catch(Exception e)
            {
                AppendShowString(e.ToString());
            }
			
		}

	}
开发者ID:ZhHong,项目名称:u3d_client,代码行数:57,代码来源:Main.cs

示例2: HandleEncryptRequest

        void HandleEncryptRequest( IPacketMsg packetMsg )
        {
            var encRequest = new Msg<MsgChannelEncryptRequest>( packetMsg );

            EUniverse eUniv = encRequest.Body.Universe;
            uint protoVersion = encRequest.Body.ProtocolVersion;

            DebugLog.WriteLine( "CMClient", "Got encryption request. Universe: {0} Protocol ver: {1}", eUniv, protoVersion );

            byte[] pubKey = KeyDictionary.GetPublicKey( eUniv );

            if ( pubKey == null )
            {
                DebugLog.WriteLine( "CMClient", "HandleEncryptionRequest got request for invalid universe! Universe: {0} Protocol ver: {1}", eUniv, protoVersion );
                return;
            }

            ConnectedUniverse = eUniv;

            var encResp = new Msg<MsgChannelEncryptResponse>();

            tempSessionKey = CryptoHelper.GenerateRandomBlock( 32 );
            byte[] cryptedSessKey = null;

            using ( var rsa = new RSACrypto( pubKey ) )
            {
                cryptedSessKey = rsa.Encrypt( tempSessionKey );
            }

            byte[] keyCrc = CryptoHelper.CRCHash( cryptedSessKey );

            encResp.Write( cryptedSessKey );
            encResp.Write( keyCrc );
            encResp.Write( ( uint )0 );

            this.Send( encResp );
        }
开发者ID:wheybags,项目名称:steamirc,代码行数:37,代码来源:CMClient.cs

示例3: HandleEncryptRequest

        void HandleEncryptRequest( IPacketMsg packetMsg )
        {
            var encRequest = new Msg<MsgChannelEncryptRequest>( packetMsg );

            EUniverse eUniv = encRequest.Body.Universe;
            uint protoVersion = encRequest.Body.ProtocolVersion;

            DebugLog.WriteLine( "UFSClient", "Got encryption request. Universe: {0} Protocol ver: {1}", eUniv, protoVersion );
            DebugLog.Assert( protoVersion == 1, "UFSClient", "Encryption handshake protocol version mismatch!" );

            byte[] randomChallenge;
            if ( encRequest.Payload.Length >= 16 )
            {
                randomChallenge = encRequest.Payload.ToArray();
            }
            else
            {
                randomChallenge = null;
            }

            byte[] pubKey = KeyDictionary.GetPublicKey( eUniv );

            if ( pubKey == null )
            {
                connection.Disconnect();

                DebugLog.WriteLine( "UFSClient", "HandleEncryptionRequest got request for invalid universe! Universe: {0} Protocol ver: {1}", eUniv, protoVersion );
                return;
            }

            ConnectedUniverse = eUniv;

            var encResp = new Msg<MsgChannelEncryptResponse>();

            var tempSessionKey = CryptoHelper.GenerateRandomBlock( 32 );
            byte[] encryptedHandshakeBlob = null;

            using ( var rsa = new RSACrypto( pubKey ) )
            {
                if ( randomChallenge != null )
                {
                    var blobToEncrypt = new byte[ tempSessionKey.Length + randomChallenge.Length ];
                    Array.Copy( tempSessionKey, blobToEncrypt, tempSessionKey.Length );
                    Array.Copy( randomChallenge, 0, blobToEncrypt, tempSessionKey.Length, randomChallenge.Length );

                    encryptedHandshakeBlob = rsa.Encrypt( blobToEncrypt );
                }
                else
                {
                    encryptedHandshakeBlob = rsa.Encrypt( tempSessionKey );
                }
            }

            var keyCrc = CryptoHelper.CRCHash( encryptedHandshakeBlob );

            encResp.Write( encryptedHandshakeBlob );
            encResp.Write( keyCrc );
            encResp.Write( ( uint )0 );

            if ( randomChallenge != null )
            {
                pendingNetFilterEncryption = new NetFilterEncryptionWithHMAC( tempSessionKey );
            }
            else
            {
                pendingNetFilterEncryption = new NetFilterEncryption( tempSessionKey );
            }

            this.Send( encResp );
        }
开发者ID:logtcn,项目名称:SteamKit,代码行数:70,代码来源:UFSClient.cs


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