예제 #1
0
    // 打开预设位
    public static void GoToPrePosition(string name, int pos)
    {
        Stream str;

        str = new MemoryStream();
        byte[] headBuff = GetSocketHeadBuff(NetProtocol.NET_GM_PROTPCOL.CTOS_GOTOPREPOSITION_MSG, (Int16)NetProtocol.Protocol.PREPOSITIONINFO_LEN);

        byte[] MSG    = new byte[NetProtocol.Protocol.PREPOSITIONINFO_LEN];
        object objMsg = NetTools.BytesToStuct(MSG, typeof(NetProtocol.PREPOSITIONINFO));

        NetProtocol.PREPOSITIONINFO pMsg = (NetProtocol.PREPOSITIONINFO)objMsg;
        pMsg.camerHander = hCurOperateCamera;
        pMsg.cName       = NetTools.CodeBytes(name, 64);
        pMsg.ret         = pos;
        byte[] ReadMsgbuff = NetTools.GetBytes(pMsg);

        byte[] PacketBuff = new byte[NetProtocol.Protocol.PREPOSITIONINFO_LEN + headBuff.Length];
        str.Write(headBuff, 0, headBuff.Length);
        str.Write(ReadMsgbuff, 0, ReadMsgbuff.Length);
        str.Position = 0;
        int r = str.Read(PacketBuff, 0, PacketBuff.Length);

        if (r > 0)
        {
            clientSocket.Send(PacketBuff, PacketBuff.Length, SocketFlags.None);
        }
    }
예제 #2
0
    //ip 172.22.20.232 userName admin pwd ""登录服务器
    public static void LogonServer(string ip, string userName, string pwd)
    {
        Stream str;

        str = new MemoryStream();
        byte[] headBuff = GetSocketHeadBuff(NetProtocol.NET_GM_PROTPCOL.CTOS_INITVIDEO_MSG, (Int16)NetProtocol.Protocol.CTOS_INITVIDEO_LEN);

        byte[] MSG    = new byte[NetProtocol.Protocol.CTOS_INITVIDEO_LEN];
        object objMsg = NetTools.BytesToStuct(MSG, typeof(NetProtocol.CMS_LogonInfo));

        NetProtocol.CMS_LogonInfo pMsg = (NetProtocol.CMS_LogonInfo)objMsg;

        pMsg.nStructVersion = 201402170;
        pMsg.srvIP          = NetTools.CodeBytes(ip, 64);
        pMsg.User           = NetTools.CodeBytes(userName, 64);
        pMsg.Passwd         = NetTools.CodeBytes(pwd, 64);
        pMsg.nProtocol      = 1;
        pMsg.nRelayMode     = 0;
        byte[] ReadMsgbuff = NetTools.GetBytes(pMsg);

        byte[] PacketBuff = new byte[NetProtocol.Protocol.CTOS_INITVIDEO_LEN + headBuff.Length];
        str.Write(headBuff, 0, headBuff.Length);
        str.Write(ReadMsgbuff, 0, ReadMsgbuff.Length);
        str.Position = 0;
        int r = str.Read(PacketBuff, 0, PacketBuff.Length);

        if (r > 0)
        {
            clientSocket.Send(PacketBuff, PacketBuff.Length, SocketFlags.None);
        }
    }
예제 #3
0
    //打开当前摄像头
    public static void openCamera(IntPtr OperateCamera, string CameraName)
    {
        Stream str;

        str = new MemoryStream();
        byte[] headBuff = GetSocketHeadBuff(NetProtocol.NET_GM_PROTPCOL.CTOS_OPENCAMERA_MSG, (Int16)NetProtocol.Protocol.CTOS_CAMERAINFO_LEN);

        byte[] MSG    = new byte[NetProtocol.Protocol.CTOS_CAMERAINFO_LEN];
        object objMsg = NetTools.BytesToStuct(MSG, typeof(NetProtocol.CTOS_CAMERAINFO));

        NetProtocol.CTOS_CAMERAINFO pMsg = (NetProtocol.CTOS_CAMERAINFO)objMsg;

        pMsg.camerHander = OperateCamera;
        pMsg.PlayerIndex = 1001;
        pMsg.cName       = NetTools.CodeBytes(CameraName, 64);

        byte[] ReadMsgbuff = NetTools.GetBytes(pMsg);

        byte[] PacketBuff = new byte[NetProtocol.Protocol.CTOS_CAMERAINFO_LEN + headBuff.Length];
        str.Write(headBuff, 0, headBuff.Length);
        str.Write(ReadMsgbuff, 0, ReadMsgbuff.Length);
        str.Position = 0;
        int r = str.Read(PacketBuff, 0, PacketBuff.Length);

        if (r > 0)
        {
            clientSocket.Send(PacketBuff, PacketBuff.Length, SocketFlags.None);
        }
    }
예제 #4
0
    //socket 握手通信
    private static void LaunchSocket(string Name)
    {
        Stream str;

        str = new MemoryStream();
        byte[] headBuff = GetSocketHeadBuff(NetProtocol.NET_GM_PROTPCOL.CTOS_CLIENTLOGIN_MSG, (Int16)NetProtocol.Protocol.CTOS_CLIENTLOGIN_LEN);

        byte[] Msgbuff = new byte[NetProtocol.Protocol.CTOS_CLIENTLOGIN_LEN];
        object objMsg  = NetTools.BytesToStuct(Msgbuff, typeof(NetProtocol.CTOS_CLIENTLOGIN));

        NetProtocol.CTOS_CLIENTLOGIN pMsg = (NetProtocol.CTOS_CLIENTLOGIN)objMsg;
        pMsg.PlayerName = NetTools.CodeBytes(Name, NetProtocol.ConstVar.ZZ_NAME_MAX + 3);
        pMsg.playerUID  = 1001;
        byte[] ReadMsgbuff = NetTools.GetBytes(pMsg);

        byte[] PacketBuff = new byte[NetProtocol.Protocol.CTOS_CLIENTLOGIN_LEN + headBuff.Length];
        str.Write(headBuff, 0, headBuff.Length);
        str.Write(ReadMsgbuff, 0, ReadMsgbuff.Length);
        str.Position = 0;
        int r = str.Read(PacketBuff, 0, PacketBuff.Length);

        if (r > 0)
        {
            clientSocket.Send(PacketBuff, PacketBuff.Length, SocketFlags.None);
        }
        return;
    }