Ejemplo n.º 1
0
 public void PushUnitData2List(FT_UnitData data)
 {
     RakNetPINVOKE.FT_UnitDataList_PushUnitData2List(swigCPtr, FT_UnitData.getCPtr(data));
     if (RakNetPINVOKE.SWIGPendingException.Pending)
     {
         throw RakNetPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Ejemplo n.º 2
0
        static void _SendUnitData (){
            FT_UnitData data = new FT_UnitData();

            BitStream writeBitStream = new BitStream();
            writeBitStream.Write((byte)FT_MessageTypes.ID_SERVER_LOGIN);
            writeBitStream.Write((byte)FT_MessageTypesNode.NODE_FT_TEST1);
            data.Serialize(true, writeBitStream);
            client.Send(writeBitStream, (char)0);
        }
Ejemplo n.º 3
0
 public override void OnProcess(FT_Session session, BitStream bsIn, AddressOrGUID systemIdentifier)
 {
     Log.Debug("FT_Node_Process_Test1.OnProcess :");
     FT_UnitData unitData = new FT_UnitData();
     unitData.Serialize(false, bsIn);
 }
Ejemplo n.º 4
0
        static void ProcessMessage(RakPeerInterface peer, RakNet.Packet packet)
        {
            if (packet != null)
            {
                if (packet.data[0] == (byte)(FT_MessageTypes.ID_SERVER_LOGIN))
                {
                    BitStream receiveBitStream = new BitStream();
                    receiveBitStream.Write(packet.data, packet.length);
                    receiveBitStream.IgnoreBytes(2);
                    FT_UnitData data = new FT_UnitData();
                    data.Serialize(false, receiveBitStream);
                    Log.Debug(" data.nGrid_x: " + data.nGrid_x);

                    BitStream writeBitStream = new BitStream();
                    writeBitStream.Write((byte)FT_MessageTypes.ID_SERVER_LOGIN);
                    writeBitStream.Write((byte)FT_MessageTypesNode.NODE_FT_TEST1);
                    data.Serialize(true, writeBitStream);
                    uint sendLength = peer.Send(writeBitStream, PacketPriority.HIGH_PRIORITY, PacketReliability.RELIABLE_ORDERED, (char)0, packet.systemAddress, false);
                    Log.Debug("SendLength = " + sendLength);
                }
            }
        }
Ejemplo n.º 5
0
        public void ProcessMessage()
        {
            while (!_bStop)
            {
                _packet = _peer.Receive();
                while (_packet != null)
                {
                    byte messageType = _packet.data[0];
                    if (messageType < (byte)DefaultMessageIDTypes.ID_USER_PACKET_ENUM)
                    {
                        DefaultMessageIDTypes idType = (DefaultMessageIDTypes)messageType;
                        switch (idType)
                        {
                            case DefaultMessageIDTypes.ID_CONNECTION_REQUEST_ACCEPTED:
                                Log.Info("In a client/server environment, our connection request to the server has been accepted.\n");
                                break;
                            case DefaultMessageIDTypes.ID_CONNECTION_ATTEMPT_FAILED:
                                Log.Info("Sent to the player when a connection request cannot be completed due to inability to connect.\n ");
                                break;
                            case DefaultMessageIDTypes.ID_ALREADY_CONNECTED:
                                Log.Info("Sent a connect request to a system we are currently connected to.\n ");
                                break;
                            case DefaultMessageIDTypes.ID_NEW_INCOMING_CONNECTION:
                                Log.Info("A remote system has successfully connected.\n");
                                break;
                            case DefaultMessageIDTypes.ID_DISCONNECTION_NOTIFICATION:
                                Log.Info(" A remote system has disconnected. \n");
                                break;
                            case DefaultMessageIDTypes.ID_CONNECTION_LOST:
                                Log.Info(" The connection to that system has been closed. \n");
                                break;
                        }
                    }
                    else
                    {
                        if (messageType == (byte)FT_MessageTypes.ID_SERVER_LOGIN)
                        {
                            byte dataType = _packet.data[1];
                            RakNet.BitStream bsIn = new RakNet.BitStream(_packet.data, _packet.length, false);
                            bsIn.IgnoreBytes(2);
                            FT_UnitData unitData = new FT_UnitData();
                            unitData.session.Serialize(false, bsIn);
                            unitData.Serialize(false, bsIn);
                            Log.Info("" + unitData.sInfo.C_String());

                            byte serverLogin = (byte)RakNet.FT_MessageTypes.ID_SERVER_LOGIN;
                            
                            RakNet.BitStream bsOut = new RakNet.BitStream();
                            bsOut.Serialize(true, ref serverLogin);
                            bsOut.Serialize(true, ref dataType);
                            unitData.session.Serialize(true, bsOut);
                            unitData.Serialize(true, bsOut);

                            uint sendLength =  _peer.Send(bsOut,
                                RakNet.PacketPriority.IMMEDIATE_PRIORITY,
                                RakNet.PacketReliability.RELIABLE_ORDERED, (char)0,
                                _packet.systemAddress,
                                false);

                            Log.Info("SendLength:" + sendLength);
                        }
                    }
                    Log.Info(string.Format("Receive Data. [0] = {0}, Length = {1}", _packet.data[0], _packet.data.Length));
                    _peer.DeallocatePacket(_packet);
                    _packet = _peer.Receive();
                }
                System.Threading.Thread.Sleep(30);
            }
        }
Ejemplo n.º 6
0
 internal static HandleRef getCPtr(FT_UnitData obj)
 {
     return((obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr);
 }
Ejemplo n.º 7
0
 internal static HandleRef getCPtr(FT_UnitData obj) {
   return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
 }
 public void PushUnitData2List(FT_UnitData data) {
   RakNetPINVOKE.FT_UnitDataList_PushUnitData2List(swigCPtr, FT_UnitData.getCPtr(data));
   if (RakNetPINVOKE.SWIGPendingException.Pending) throw RakNetPINVOKE.SWIGPendingException.Retrieve();
 }