Exemplo n.º 1
0
    private static void WalkDirectoryTree(DirectoryInfo root, string rootDicName)
    {
        FileInfo[]      files   = null;
        DirectoryInfo[] subDirs = null;
        subDirs = root.GetDirectories();
        foreach (DirectoryInfo dirInfo in subDirs)
        {
            WalkDirectoryTree(dirInfo, rootDicName + dirInfo.Name + "/");
        }

        files = root.GetFiles("*.proto");
        if (files != null)
        {
            foreach (FileInfo fi in files)
            {
                string protoFileName = rootDicName + fi.Name;
                SetupArgs(protoFileName);
                _process.Start();

                while (!_process.StandardError.EndOfStream)
                {
                    SDebug.LogError(_process.StandardError.ReadLine());
                }
            }
        }
    }
Exemplo n.º 2
0
    private void Recv()
    {
        if (NowConnected() && _socket.Available > 0)
        {
            try {
                int recvSize = Math.Min(_socket.Available, _recvBufferSize - _recvBuffer.Length);
                int ret      = _socket.Receive(_recvBuffer, _recvBuffer.Length, recvSize, SocketFlags.None);

                /* 检测数据接收缓冲区的大小是否大于数据头的大小
                 * 解析数据头,获取后续数据包的大小或者直接返回
                 * 判断数据接收缓冲区剩下的大小(减去数据头的大小)是否大于后续数据包的大小
                 * 解析数据包或者直接返回
                 */

                if (_recvBuffer.Length < _headerSize)
                {
                    return;
                }
            } catch (SocketException e) {
                SDebug.LogError(e.ToString());
                SDebug.LogError("ErrorCode: ", e.ErrorCode);
            } catch (ObjectDisposedException e) {
                SDebug.LogError(e.ToString());
            }
        }
    }
Exemplo n.º 3
0
    public void Update()
    {
        switch (_curState)
        {
        case SocketState.idle:
            Setup();
            break;

        case SocketState.connectFaild:
            TryConnect();
            break;

        case SocketState.connecting:
            break;

        case SocketState.connected:
            if (!NowConnected())
            {
                TryConnect();
                return;
            }

            Send();
            Recv();

            break;

        default:
            SDebug.LogError("Socket State Error");
            break;
        }
    }
Exemplo n.º 4
0
    // 发送数据接口
    public void SendByServerType(ServerType type, byte[] data)
    {
        XYSocketClient sc;

        if (!socketNodeDic.TryGetValue(type, out sc))
        {
            SDebug.LogError("Server Type Not Found");
            return;
        }

        sc.PushSendRequest(data);
    }
Exemplo n.º 5
0
 private void Send()
 {
     if (NowConnected())
     {
         try {
             while (_sendDataQueue.Count > 0)
             {
                 // 发送数据大小检测
                 byte[] data = _sendDataQueue.Dequeue();
                 int    ret  = _socket.Send(data);
             }
         } catch (SocketException e) {
             SDebug.LogError(e.ToString());
             SDebug.LogError("ErrorCode: ", e.ErrorCode);
         } catch (ObjectDisposedException e) {
             SDebug.LogError(e.ToString());
         }
     }
 }