コード例 #1
0
    static int _CreateTCPConnectMsg(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 3)
            {
                ushort        arg0 = (ushort)LuaDLL.luaL_checknumber(L, 1);
                string        arg1 = ToLua.CheckString(L, 2);
                ushort        arg2 = (ushort)LuaDLL.luaL_checknumber(L, 3);
                TCPConnectMsg obj  = new TCPConnectMsg(arg0, arg1, arg2);
                ToLua.PushObject(L, obj);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: TCPConnectMsg.New"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
コード例 #2
0
    public override void ProcessEvent(MsgBase tmpMsg)
    {
        //throw new System.NotImplementedException();
        switch (tmpMsg.msgId)
        {
        case (ushort)TCPEvent.TcpConnect:
        {
            TCPConnectMsg connectMsg = (TCPConnectMsg)tmpMsg;
            socket = new NetWorkToServer(connectMsg.ip, connectMsg.port);
        }
        break;

        case (ushort)TCPEvent.TcpSendMsg:
        {
            TCPMsg sendMsg = (TCPMsg)tmpMsg;
            socket.PutSendMsgToPool(sendMsg.netMsg);
        }
        break;

        case (ushort)TCPEvent.TcpSendLoginMsg:
        {
            TCPMsg sendMsg = (TCPMsg)tmpMsg;
            socket.PutSendMsgToPool(sendMsg.netMsg);
        }
        break;
        }
    }
コード例 #3
0
    public override void ProccessEvent(MsgBase tmpMsg)
    {
        switch (tmpMsg.msgId)
        {
        case (ushort)TCPEvent.eTcpConnect:
            TCPConnectMsg connectMsg = (TCPConnectMsg)tmpMsg;
            socket = new NetWorkToServer(connectMsg.ip, connectMsg.port);
            break;

        case (ushort)TCPEvent.eTcpSendMsg:
            TCPMsg sendMsg = (TCPMsg)tmpMsg;
            socket.PutSendMsgToPool(sendMsg.netMsg);
            break;
        }
    }
コード例 #4
0
    static int set_ip(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            TCPConnectMsg obj  = (TCPConnectMsg)o;
            string        arg0 = ToLua.CheckString(L, 2);
            obj.ip = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index ip on a nil value" : e.Message));
        }
    }
コード例 #5
0
    static int get_port(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            TCPConnectMsg obj = (TCPConnectMsg)o;
            ushort        ret = obj.port;
            LuaDLL.lua_pushnumber(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index port on a nil value" : e.Message));
        }
    }
コード例 #6
0
    static int get_ip(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            TCPConnectMsg obj = (TCPConnectMsg)o;
            string        ret = obj.ip;
            LuaDLL.lua_pushstring(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index ip on a nil value" : e.Message));
        }
    }
コード例 #7
0
    static int set_port(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            TCPConnectMsg obj  = (TCPConnectMsg)o;
            ushort        arg0 = (ushort)LuaDLL.luaL_checknumber(L, 2);
            obj.port = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index port on a nil value" : e.Message));
        }
    }
コード例 #8
0
    public override void ProcessEvent(MsgBase msg)
    {
        switch (msg.msgID)
        {
        case (ushort)TCPEvent.Connect: {
            TCPConnectMsg connectMsg = (TCPConnectMsg)msg;
            netWorkToServer = new NetTcpWorkToServer(connectMsg.ip, connectMsg.port);
        }
        break;

        case (ushort)TCPEvent.SendMsg: {
            TCPSocketMsg sendMsg = (TCPSocketMsg)msg;
            netWorkToServer.PutSendMsgToPool(sendMsg.netMsg);
        }
        break;
        }
    }
コード例 #9
0
ファイル: TcoSocket.cs プロジェクト: 756915370/Unity_Frame
    public override void ProcessEvent(MsgBase msg)
    {
        switch ((TCPEvent)msg.msgId)
        {
        case TCPEvent.TcpConnect:
            TCPConnectMsg connectMsg = (TCPConnectMsg)msg;
            netWorkToServer = new NetWorkToServer(connectMsg.ip, connectMsg.port);
            break;

        case TCPEvent.TcpSendMsg:
            TCPMsg sendMsg = (TCPMsg)msg;
            netWorkToServer.PutSendMsgPool(sendMsg.netMsg);

            break;

        default:
            break;
        }
    }
コード例 #10
0
    private void TcpConnectButtonClick()
    {
        TCPConnectMsg msg = new TCPConnectMsg((ushort)TCPEvent.TcpConnect, "127.0.0.1", 8888);

        SendMsg(msg);
    }