Esempio n. 1
0
        public void ConnectTest(string ip, int port)
        {
            MPNetClient mpnet = new MPNetClient(m_PrefabConnecterId);

            mpnet.Connect(ip, port);

            mpnet.AddEventListener(MPEvent.CONNECTION, delegate(BaseEvent evt)
            {
                Hashtable par = evt.Params;
                if ((bool)par["success"])
                {
                    DispatchEvent(new MPEvent(Program.EVENT_CONNECT + m_PrefabConnecterId));
                }
                else
                {
                    DispatchEvent(new MPEvent(Program.EVENT_CONNECT_LOST + m_PrefabConnecterId));
                }
            });
            mpnet.AddEventListener(MPEvent.CONNECTION_LOST, delegate(BaseEvent evt)
            {
                GTLib.NetManager.KillConnection(m_PrefabConnecterId);
                DispatchEvent(new MPEvent(Program.EVENT_CONNECT_LOST + m_PrefabConnecterId));
            });

            GTLib.NetManager.AddMPNetClient(mpnet);
        }
Esempio n. 2
0
 public override void Validate(MPNetClient mpnet)
 {
     if (mpnet.MySelf == null)
     {
         throw new Exception("LogoutRequest Error You are not logged in at the moment!");
     }
 }
Esempio n. 3
0
 public override void Validate(MPNetClient mpnet)
 {
     if (mpnet.MySelf != null)
     {
         throw new Exception("LoginRequest Error You are already logged in. Logout first");
     }
 }
Esempio n. 4
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="ip"></param>
    /// <param name="port"></param>
    public void Connect(string ip, int port)
    {
        MPNetClient mpnet = new MPNetClient(m_PrefabConnecterId);

        mpnet.Connect(ip, port);

        mpnet.AddEventListener(MPEvent.CONNECTION, delegate(BaseEvent evt)
        {
            IMPObject par = evt.Params;
            if ((bool)par["success"])
            {
                IMPObject mpo  = MPObject.NewInstance();
                mpo["test1"]   = 22;
                mpo["test2"]   = 22;
                mpo["test3"]   = 33;
                LuaTable table = mpo.ToLuaTable();
                GTLib.NetManager.DispatchLuaEvent("conn1", table);
            }
            else
            {
                GTLib.NetManager.DispatchLuaEvent("lost1", null);
            }
        });
        mpnet.AddEventListener(MPEvent.CONNECTION_LOST, delegate(BaseEvent evt)
        {
            GTLib.NetManager.KillConnection(m_PrefabConnecterId);
            GTLib.NetManager.DispatchLuaEvent("lost1", null);
        });

        GTLib.NetManager.AddMPNetClient(mpnet);
    }
Esempio n. 5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sfs"></param>
 public UDPSocketLayer(MPNetClient sfs)
 {
     //this.sfs = sfs;
     if (sfs != null)
     {
         this.log = sfs.Log;
     }
 }
Esempio n. 6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="bitSwarm"></param>
 public BaseController(BitSwarmClient bitSwarm)
 {
     this.bitSwarm = bitSwarm;
     if (bitSwarm != null)
     {
         log   = bitSwarm.Log;
         mpnet = bitSwarm.MPNet;
     }
 }
Esempio n. 7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sfs"></param>
 public BitSwarmClient(MPNetClient mpnet)
 {
     controllers            = new Dictionary <int, IController>();
     compressionThreshold   = 0x1e8480;
     maxMessageSize         = 0x2710;
     reconnectionSeconds    = 0;
     attemptingReconnection = false;
     manualDisconnection    = false;
     retryTimer             = null;
     this.mpnet             = mpnet;
     log = mpnet.Log;
 }
Esempio n. 8
0
 public override void Execute(MPNetClient mpnet)
 {
     mpo.PutUtfString(KEY_USER_NAME, this.userName);
     if (password.Length > 0)
     {
         password = MD5Hash(password);
     }
     mpo.PutUtfString(KEY_PASSWORD, this.password);
     if (this.parameters != null)
     {
         mpo.PutMPObject(KEY_PARAMS, this.parameters);
     }
 }
Esempio n. 9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="mpnet"></param>
 public UDPManager(MPNetClient mpnet)
 {
     this.mpnet = mpnet;
     packetId   = 0L;
     if (mpnet != null)
     {
         log = mpnet.Log;
     }
     else
     {
         log = new Logger(typeof(UDPManager));
     }
     currentAttempt = 1;
 }
Esempio n. 10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sfs"></param>
        public override void Validate(MPNetClient sfs)
        {
            List <string> errors = new List <string>();

            if ((extCmd == null) || (extCmd.Length == 0))
            {
                errors.Add("Missing extension command");
            }
            if (parameters == null)
            {
                errors.Add("Missing extension parameters");
            }
            if (errors.Count > 0)
            {
                string msg = "";
                foreach (string err in errors)
                {
                    msg = msg + err;
                }
                throw new Exception(msg);
            }
        }
Esempio n. 11
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sfs"></param>
 public override void Execute(MPNetClient sfs)
 {
     mpo.PutUtfString(KEY_CMD, extCmd);
     mpo.PutMPObject(KEY_PARAMS, parameters);
 }
Esempio n. 12
0
 public virtual void Validate(MPNetClient mpnet)
 {
 }
Esempio n. 13
0
 public virtual void Execute(MPNetClient mpnet)
 {
 }