Ejemplo n.º 1
0
        //public void _NetworkChangeState( object source, NetworkChangeStateArgs e )
        //{
        //  isserver = e.IsServer;
        //}

        // rpc format:
        // (classname)(methodname)(arg1)(arg2)(arg3)...
        // SendRpc( connection, "OSMP.Testing.ITestInterface", "SayHello",  new object[]{  } )
        public void SendRpc(IPEndPoint connection, string typename, string methodname, object[] args)
        {
            // Test.WriteOut( args );
            LogFile.WriteLine("SendRpc " + typename + " " + methodname);
            //for( int i = 0; i < args.GetUpperBound(0) + 1; i++ )
            //{
            //  LogFile.WriteLine("  arg: " + args[i].ToString() );
            //}

            byte[] packet       = new byte[1400]; // note to self: make this a little more dynamic...
            int    nextposition = 0;

            //binarypacker.WriteValueToBuffer(packet, ref nextposition, RpcType);
            binarypacker.WriteValueToBuffer(packet, ref nextposition, typename);
            binarypacker.WriteValueToBuffer(packet, ref nextposition, methodname);
            foreach (object parameter in args)
            {
                binarypacker.WriteValueToBuffer(packet, ref nextposition, parameter);
            }

            //LogFile.WriteLine("Sending " + Encoding.UTF8.GetString(packet, 0, nextposition));
            //LogFile.WriteLine( nextposition + " bytes " + Encoding.ASCII.GetString( packet, 0, nextposition ) );
            network.Send(connection, RpcType, packet, 0, nextposition);
        }
Ejemplo n.º 2
0
 void net_ReceivedPacket(NetworkLevel2Connection net2con, byte[] data, int offset, int length)
 {
     LogFile.WriteLine("TestLevel2Client Received packet: " + Encoding.UTF8.GetString(data, offset, length));
     net.Send(net2con.connectioninfo.Connection, 'Z', Encoding.UTF8.GetBytes("Test reply from client"));
 }