コード例 #1
0
ファイル: NetSock.cs プロジェクト: euOnmyoji/LuaSTG-EX-Plus
 //==================
 public void Reset()
 {
     Stop();
     rwlock_object.EnterWriteLock();
     try {
         if (STATE != SERVERSTATE.FREE)
         {
             listener_object = null;
             send_buffer.Clear();
             receive_buffer.Clear();
             STATE = SERVERSTATE.FREE;
             logger.Print(LOGLEVEL.INFO, "Broadcast server reset.");
         }
     }
     finally {
         rwlock_object.ExitWriteLock();
     }
 }
コード例 #2
0
ファイル: NetSock.cs プロジェクト: euOnmyoji/LuaSTG-EX-Plus
        //==================
        public BroadcastServer(LOGGER logObj)
        {
            logger          = logObj;
            rwlock_object   = new ReaderWriterLockSlim();
            listener_object = null;
            //准备客户端
            int count = (int)GLOBAL.NETSOCK_MAX_CLIENT_COUNT;

            client_object = new TCPObject[count];
            for (int i = 0; i < count; i++)
            {
                client_object[i] = new TCPObject(logObj);
            }
            //buffer
            send_buffer    = new StringBuffer();
            receive_buffer = new StringBuffer();
            STATE          = SERVERSTATE.FREE;
        }
コード例 #3
0
ファイル: NetSock.cs プロジェクト: euOnmyoji/LuaSTG-EX-Plus
        public bool Init(int port)
        {
            Reset();
            bool state = true;

            rwlock_object.EnterWriteLock();
            try {
                listener_object = new TCPListener(logger);
                listener_object.Bind(port);
                if (listener_object.STATE == TCPSTATE.INSTALL)
                {
                    STATE = SERVERSTATE.INSTALL;
                    logger.Print(LOGLEVEL.INFO, "Broadcast server init succesfully.");
                }
                else
                {
                    state = false;
                }
            }
            finally {
                rwlock_object.ExitWriteLock();
            }
            return(state);
        }