예제 #1
0
파일: Event.php 프로젝트: eseawind/qian_dao
 /**
  * 有消息时触发该方法
  * @param int $client_id 发消息的client_id
  * @param string $message 消息
  * @return void
  */
 public static function onMessage($client_id, $message)
 {
     $db = \Lib\Db::instance('tc504');
     $nowtime = idate("U");
     $ok = "right";
     $error = "error";
     $sqlok = "sql right!";
     $sqlerror = "sql error!";
     if ($message[0] == '{') {
         $message = JsonProtocol::decode($message);
         $sqldidian = $message['ID'];
         $sqlshidu = $message['humidity'];
         $sqlwendu = $message['temperature'];
         $insert_id = $db->insert('wenshidu')->cols(array('didian' => $sqldidian, 'shidu' => $sqlshidu, 'wendu' => $sqlwendu, 'time' => $nowtime))->query();
         GateWay::sendToClient($client_id, TextProtocol::encode($insert_id));
     } else {
         $message = TextProtocol::decode($message);
         $commend = trim($message);
         $ret = $db->select('ui_cardid')->from('tbl_user')->where("ui_cardid = '{$commend}' ")->single();
         if ($commend === $ret) {
             $insert_id = $db->insert('tbl_log')->cols(array('log_card' => $commend, 'log_time' => $nowtime))->query();
             if ($insert_id === 1) {
                 GateWay::sendToClient($client_id, TextProtocol::encode($sqlok));
             } else {
                 GateWay::sendToClient($client_id, TextProtocol::encode($sqlerror));
             }
         } else {
             GateWay::sendToClient($client_id, TextProtocol::encode($error));
         }
     }
 }
예제 #2
0
 public function __Construct()
 {
     $this->_store = Store::instance('game');
     $this->_db = Db::instance('passport');
     $this->_pbMember = new PbMember();
     $this->_pbResult = new PbResult();
 }
예제 #3
0
 /**
  * 获取在线数据
  * @param null $sid 服务器ID
  * @return mixed
  */
 public static function getOnline($sid = null)
 {
     if (is_null($sid)) {
         $where = 'WHERE 1=1';
     } else {
         $where = "WHERE s_id = {$sid}";
     }
     $db = Db::instance('passport');
     $sql = "SELECT COUNT(*) AS totle FROM `t_online` {$where}";
     $result = $db->single($sql);
     return $result;
 }
예제 #4
0
 /**
  * @return mixed
  */
 public static function getServerList()
 {
     $store = Store::instance('game');
     $db = Db::instance('passport');
     $key = "GAME_ZONE_SERVER_LIST";
     $serverList = $store->get($key);
     if ($serverList) {
         return $serverList;
     }
     $sql = "SELECT s_id,s_name,s_type,s_ip FROM `t_server`\n                WHERE s_status=1\n                ORDER BY s_id ASC";
     $result = $db->query($sql);
     if ($result) {
         $store->set($key, $result);
     }
     return $result;
 }
예제 #5
0
 public static function report($data)
 {
     $db = Db::instance('passport');
     $result = $db->insert('t_statistic')->cols($data)->query();
     return $result;
 }
예제 #6
0
 public function __Construct()
 {
     $this->_db = Db::instance('passport');
     $this->_pbResult = new PbResult();
 }
예제 #7
0
 public function __Construct()
 {
     $this->_store = Store::instance('game');
     $this->_db = Db::instance('passport');
 }