Example #1
0
 void HeartFPS()
 {
     if (!HeartFPSManager.Instance.VerifyLoseConnection())
     {
         var index = HeartFPSManager.Instance.MakeHeartFps();
         if (index != 0)
         {
             ushort delay = HeartFPSManager.Instance.GetLastDelay(index);
             netWorkCode = NetServiceManager.Instance.EntityService.SendActionHeartFPS(index, delay);
             //Debug.Log("111111netWorkCode===="+netWorkCode);
             CheckNetWork();
             //NetServiceManager.Instance.EntityService.SendActionHeartFPS(index);
         }
     }
     else
     {
         //Debug.Log("2222222netWorkCode===="+netWorkCode);
         if (isIDKickedMark)
         {
             return;
         }
         RaiseEvent(EventTypeEnum.LostConect.ToString(), null);
         LostConect();
     }
 }
Example #2
0
    public SERVICE_CODE UDPSpecSend(Package pkg, IpInfo?targetIpInfo)
    {
        byte         command = pkg.GetMasterMsgType();
        SERVICE_CODE ret     = SERVICE_CODE.SUCCESS;

        if (!ServiceManager.UDPSpecSend(pkg, targetIpInfo))
        {
            ret = SERVICE_CODE.ERROR_NOFOUND;
        }

        return(ret);
    }
Example #3
0
    public SERVICE_CODE Broadcast(Package pkg)
    {
        byte         command = pkg.GetMasterMsgType();
        SERVICE_CODE ret     = SERVICE_CODE.SUCCESS;

        if (!ServiceManager.UDPBroadcast(pkg))
        {
            ret = SERVICE_CODE.ERROR_NOFOUND;
        }

        return(ret);
    }
Example #4
0
    public static SERVICE_CODE ConnectToService(SocketInfoType socketInfoType)
    {
        SERVICE_CODE  service_code=SERVICE_CODE.SUCCESS;
        int socketType = (int)socketInfoType;
        if (!connectorMap.ContainsKey(socketType))
        {
            //CommonTrace.Log("ConnectToService");
            if (AddrConfMap.ContainsKey(socketType))
            {
                //CommonTrace.Log("AddrConfMap.ContainsKey(socketType)");
                IpInfo info = AddrConfMap[socketType];
                switch (info.baseType)
                {
                    case BASESOCKET_TYPE.SOCKET_TCP:
                        TcpSocket tcpSocket = new TcpSocket();
                        try
                        {
                            SOCKET_CODE socketCode= tcpSocket.SocketConnect(info.ip, info.port);
                            if (socketCode == SOCKET_CODE.SUCCESS)
                            {
                                connectorMap[socketType] = tcpSocket;
                            }
                            else
                            {
                                service_code = SERVICE_CODE.ERROR_CONNECT;
                            }
                        }
                        catch (System.Exception)
                        {
                            service_code= SERVICE_CODE.ERROR_CONNECT;
                        }
                        break;

                    case BASESOCKET_TYPE.SOCKET_UDP:
                        UdpSocket udpSocket = new UdpSocket();
                        udpSocket.SetRemote(info.ip, info.port);
                        connectorMap[socketType] = udpSocket;
                       
                        break;

                    default:
                        break;
                }
            }
            else
            {
                //CommonTrace.Log("!AddrConfMap.ContainsKey(socketType)");
                service_code = SERVICE_CODE.ERROR_NOCONF;
            }
        }
        return service_code;
    }
Example #5
0
 private static SERVICE_CODE PrepareUDPSocket()
 {
     SERVICE_CODE service_code = SERVICE_CODE.SUCCESS;
     int socketType = (int)SocketInfoType.UDPServer;
     if (!connectorMap.ContainsKey(socketType))
     {
          if (AddrConfMap.ContainsKey(socketType))
         {
             IpInfo info = AddrConfMap[socketType];
             UdpSocket udpSocket = new UdpSocket();
             udpSocket.SetRemote(info.ip, info.port);
             connectorMap[socketType] = udpSocket;
          }
         else
         {
             service_code = SERVICE_CODE.ERROR_NOCONF;
         }
     }
     return service_code;
 }
Example #6
0
    public SERVICE_CODE Request(Package pkg)
    {
        byte command = pkg.GetMasterMsgType();

#if UNITY_EDITOR
        String[] logText = new String[3];
        logText[0] = "Send:" + System.DateTime.Now.ToLocalTime().ToString();
        logText[1] = pkg.Head.MasterMsgType.ToString();
        logText[2] = pkg.Head.SubMsgType.ToString();
        LogManager.Instance.WriteLog("NetResponse", logText);
#endif


        SERVICE_CODE ret = SERVICE_CODE.SUCCESS;

        if (!ServiceManager.RequestService(SocketInfoType, pkg))
        {
            ret = SERVICE_CODE.ERROR_NOFOUND;
        }

        return(ret);
    }