stanley-king пре 6 година
родитељ
комит
297c8d9bf8

+ 5 - 0
data/model/room.model.php

@@ -64,6 +64,11 @@ class roomModel extends Model
         return $this->table('room_msg')->insert($datas);
     }
 
+    public function addChatwoMsg($datas)
+    {
+        return $this->table('room_chatwo_msg')->insert($datas);
+    }
+
     public function getRoomExtend($userid,$lock=false)
     {
         $item = $this->table('room_extend')->field('*')->where(['userid' => $userid])->lock($lock)->find();

+ 0 - 17
helper/room/access_client.php

@@ -40,21 +40,4 @@ class access_client extends tcp_client
         $port = $config['room_srv']['port'];
         return "tcp://{$host}:{$port}";
     }
-
-    public function join($room,$room_key)
-    {
-        $param = ["act" => 'factory','op' => 'create', "type" => 'bargain_goods','params' => ['goods_id' => $goods_id,'user' => $user]];
-
-        $result = $this->request($param);
-        if(empty($result)) return false;
-
-        $code = intval($result['code']);
-        if($code != 200) {
-            return false;
-        }
-        else {
-            return true;
-        }
-    }
-
 }

+ 24 - 2
helper/room/author.php

@@ -11,9 +11,31 @@ namespace room;
 
 class author
 {
-    static public function sign_web($roomid,$userid,$room_type)
+    static public function sign_web($roomid,$userid)
     {
-        $data = ['room' => $roomid,'user' => $userid,'room_type' => $room_type];
+        $data = ['room' => $roomid,'user' => $userid,'acctype' => proto_type::acc_web_type];
+        $plaintext = json_encode($data);
+
+        $cipher="AES-128-CBC";
+        $ivlen = openssl_cipher_iv_length($cipher);
+        $iv = self::zero_iv($ivlen);
+        return openssl_encrypt($plaintext, $cipher, self::passwd(), 0, $iv);
+    }
+
+    static public function sign_native($userid)
+    {
+        $data = ['user' => $userid,'room' => 0,'acctype' => proto_type::acc_native_type];
+        $plaintext = json_encode($data);
+
+        $cipher="AES-128-CBC";
+        $ivlen = openssl_cipher_iv_length($cipher);
+        $iv = self::zero_iv($ivlen);
+        return openssl_encrypt($plaintext, $cipher, self::passwd(), 0, $iv);
+    }
+
+    static public function sign_all($userid)
+    {
+        $data = ['user' => $userid,'room' => 0,'acctype' => proto_type::acc_all_type];
         $plaintext = json_encode($data);
 
         $cipher="AES-128-CBC";

+ 19 - 30
helper/room/base_room.php

@@ -15,7 +15,7 @@ use Exception;
 abstract class base_room extends base_info
 {
     protected $mRoomid;
-    protected $mParticipants; //每个人都有一个唯一的roomkey
+    protected $mParticipants;
     protected $mRoomType;
     protected $mod_room;
     protected $mCurRespMsgs;
@@ -113,32 +113,13 @@ abstract class base_room extends base_info
             return false;
         }
     }
-
-    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-    public function leaveOp($input)
-    {
-        $this->clear();
-
-        $room_key = $input['room_key'];
-        $userinfo = $this->find($room_key);
-        if($userinfo == false) return false;
-
-        if($this->leave($room_key)) {
-            $this->add_return([$room_key],'ret_leave',$userinfo);
-            $this->add_broad('leave',$userinfo);
-            return true;
-        }
-        else {
-            return false;
-        }
-    }
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     public function messageOp($input)
     {
         $this->clear();
-        $room_key = $input['room_key'];
+        $user = $input['user'];
 
-        $userinfo = $this->find($room_key);
+        $userinfo = $this->find($user);
         if($userinfo == false) return false;
 
         $type = $this->validate_type($input['type']);
@@ -147,7 +128,8 @@ abstract class base_room extends base_info
         if($type == false || $content == false) return false;
 
         $this->record_message($userinfo['userid'],$type,$content);
-        $this->add_broad('message',['from' => $userinfo,'type' => $type,'content' => $content]);
+        $this->add_broad('message',['from' => $userinfo,'type' => $input['type'],'content' => $content]);
+        $this->add_return([$user],'message',['from' => $userinfo,'type' => $input['type'],'content' => $content]);
 
         return true;
     }
@@ -194,13 +176,16 @@ abstract class base_room extends base_info
         $this->mCurRespMsgs['broadcast'] = [];
     }
 
-    protected function add_return(array $roomkeys,$op,$content)
+    protected function add_return(array $users, $op, $content)
     {
         $msg = [];
-        $msg['receivers'] = ['type' => 'roomkey', 'users' => $roomkeys];
-        $msg['room'] = $this->mRoomid;
+
         $msg['act']  = "room";
-        $msg['op']   = $op;
+        $msg['op']   = "relay";
+        $msg['relay_type'] = "roomusers";
+        $msg['receivers'] = $users;
+        $msg['room'] = $this->mRoomid;
+        $msg['receiver_type'] = $this->room_type();
 
         $msg['body']['act']  = 'room';
         $msg['body']['op']   = $op;
@@ -213,10 +198,14 @@ abstract class base_room extends base_info
     protected function add_broad($op,$content)
     {
         $msg = [];
-        $msg['receivers'] = ['type' => 'broadcast'];
-        $msg['room'] = $this->mRoomid;
+
         $msg['act']  = "room";
-        $msg['op']   = $op;
+        $msg['op']   = "relay";
+        $msg['relay_type'] = "room";
+        $msg['receivers'] = [];
+        $msg['room'] = $this->mRoomid;
+        $msg['receiver_type'] = $this->room_type();
+
 
         $msg['body']['act']  = 'room';
         $msg['body']['op']   = $op;

+ 3 - 3
helper/room/chatwo_room.php

@@ -8,11 +8,11 @@
 
 namespace room;
 
-class chatwo_room extends base_room
+class chat_room extends base_room
 {
     public function __construct($cinfos, $participants = [])
     {
-        $this->mRoomType = 'chatwo';
+        $this->mRoomType = 'chat';
         parent::__construct($cinfos,$participants);
     }
-}
+}

+ 114 - 0
helper/room/chatwo.php

@@ -0,0 +1,114 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: stanley-king
+ * Date: 2018/7/7
+ * Time: 下午11:29
+ */
+
+namespace room;
+
+use Exception;
+use Log;
+use member_info;
+
+class chatwo
+{
+    protected $mUserInfos;
+    private   $mod_room;
+
+
+    public function __construct()
+    {
+        $this->mUserInfos = [];
+        $this->mod_room = Model('room');
+    }
+
+    public function messageOp($input)
+    {
+        $from = intval($input['from']);
+        $to   = intval($input['to']);
+
+        if($from <= 0 || $to <= 0) return false;
+
+        $finfo = $this->find($from);
+        $tinfo = $this->find($to);
+        if($tinfo == false || $tinfo == false) return false;
+
+        $type = $this->validate_type($input['type']);
+        $content = $this->validate_content($input['content']);
+
+        if($type == false || $content == false) return false;
+
+        $this->record_message($from,$to,$type,$content);
+        $msg = ['from' => $finfo,'content' => $content, 'type' => $input['type']];
+        return $this->format_msg($from,$to,"message",$msg);
+    }
+
+    private function format_msg($from,$to,$op,$content)
+    {
+        $msg = [];
+
+        $msg['act']  = "room";
+        $msg['op']   = "relay";
+        $msg['relay_type'] = "users";
+        $msg['receivers'] = [$from,$to];
+        $msg['room'] = 0;
+        $msg['receiver_type'] = proto_type::sroom_chatwo;
+
+        $msg['body']['act']  = proto_type::act_chatwo;
+        $msg['body']['op']   = $op;
+        $msg['body']['content'] = $content;
+
+        return $msg;
+    }
+
+    protected function find($userid)
+    {
+        try
+        {
+            if(array_key_exists($userid,$this->mUserInfos)) {
+                return $this->mUserInfos[$userid];
+            }
+            else {
+                $item = Model('member')->getMemberInfoByID($userid);
+                $uinfo = new member_info($item);
+                $result = ['nickname' => $uinfo->nickname(),'avatar' => $uinfo->avatar(),'userid' => intval($userid)];
+                $this->mUserInfos[$userid] = $result;
+                return $result;
+            }
+        }
+        catch (Exception $ex)
+        {
+            Log::record($ex->getMessage(),Log::ERR);
+            return false;
+        }
+    }
+
+    //////////////////////////////////////消息验证、返回、广播//////////////////////////////////////////////////////////////
+    protected function validate_type($type)
+    {
+        $stype = strtolower($type);
+        if($stype == proto_type::msg_stype_text) {
+            return proto_type::msg_type_text;
+        }
+        elseif($stype == proto_type::msg_stype_pic) {
+            return proto_type::msg_type_text;
+        }
+        elseif($stype == proto_type::msg_stype_bargain) {
+            return proto_type::msg_type_bargain;
+        }
+        else {
+            return false;
+        }
+    }
+    protected function validate_content($content)
+    {
+        return $content;
+    }
+
+    protected function record_message($from,$to,$type,$content)
+    {
+        $this->mod_room->addChatwoMsg(['from_user' => $from,'to_user' =>$to, 'type' => $type,'msg' => $content,'add_time' => time(),'state' => 0]);
+    }
+}

+ 3 - 6
helper/room/factory.php

@@ -23,13 +23,13 @@ class factory
     public function create($params)
     {
         $type = $params['type'];
-        if($type == proto_type::act_bargain) {
+        if($type == proto_type::sroom_bargain) {
             return $this->create_bargain($params);
         }
-        elseif($type == proto_type::act_group) {
+        elseif($type == proto_type::sroom_group) {
             return $this->create_group($params);
         }
-        elseif($type == proto_type::act_shake_bonus) {
+        elseif($type == proto_type::sroom_shake_bonus) {
             return $this->create_shake_bonus($params);
         }
         else {
@@ -55,13 +55,10 @@ class factory
         elseif($rinfo->type() == proto_type::room_shake_bonus) {
             return new shake_room($room_params,$participants);
         }
-        elseif ($rinfo->type() == proto_type::room_chatwo) {
-        }
         else {
             return false;
         }
     }
-
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
     private function create_bargain($params)

+ 15 - 0
helper/room/factory_client.php

@@ -137,4 +137,19 @@ class factory_client extends tcp_client
             return $result['data'];
         }
     }
+
+    public function push($content)
+    {
+        $param = ["act" => 'factory','op' => 'push','content' => $content];
+        $result = $this->request($param);
+        if(empty($result)) return false;
+
+        $code = intval($result['code']);
+        if($code != 200) {
+            return false;
+        }
+        else {
+            return true;
+        }
+    }
 }

+ 22 - 0
helper/room/factory_processor.php

@@ -126,6 +126,16 @@ class factory_processor implements IProcessor
                 return $this->error(errcode::ErrRoomInvite);
             }
         }
+        elseif($op == 'push')
+        {
+            $content = $input['content'];
+            $ret = $this->push($content);
+            if($ret != false) {
+                return $this->success(NULL);
+            } else {
+                return $this->error(errcode::ErrRoomPush);
+            }
+        }
         else {
             return $this->error(errcode::ErrRoomFactoryOp);
         }
@@ -177,6 +187,18 @@ class factory_processor implements IProcessor
         }
     }
 
+    private function push($content)
+    {
+        foreach ($this->mRoomClients as  $client)
+        {
+            $ret = $client->push($content);
+            if($ret != false) {
+                return true;
+            }
+        }
+        return false;
+    }
+
     private function room_client()
     {
         $count = count($this->mRoomClients);

+ 2 - 9
helper/room/group_room.php

@@ -9,18 +9,11 @@
 namespace room;
 
 
-class group_room extends base_room
-{
-    public function __construct($cinfos, array $participants = [])
-    {
-        parent::__construct($cinfos, $participants);
-    }
-}
-
-class shake_room extends group_room
+class shake_room extends base_room
 {
     public function __construct($cinfos, array $participants = [])
     {
+        $this->mRoomType = 'shake_bonus';
         parent::__construct($cinfos, $participants);
     }
     public function shakeOp($input)

+ 22 - 8
helper/room/proto_type.php

@@ -11,24 +11,38 @@ namespace room;
 
 class proto_type
 {
+    //消息类型
     const act_factory = 'factory';
+    const act_room    = 'room';
+    const act_access  = 'access';
+    const act_chatwo  = 'chatwo';
+    const act_push    = 'push';
 
-    const act_bargain  = 'bargain_goods';
+    //房间类型
+    const sroom_bargain  = 'bargain_goods';
     const room_bargain = 1;
 
-    const act_group    = 'group';
+    const sroom_group    = 'group';
     const room_group   = 2;
 
-    const act_chatwo   = 'chatwo';
-    const room_chatwo  = 3;
+    const sroom_chat   = 'chat';
+    const room_chat   = 3;
 
-    const act_shake_bonus    = 'shake_bonus';
-    const room_shake_bonus   = 4;
+    const sroom_shake_bonus = 'shake_bonus';
+    const room_shake_bonus  = 4;
 
-    const act_award    = 'award';
+    const sroom_award    = 'award';
     const room_award   = 5;
 
-    const act_access = 'access';
+    const sroom_chatwo = 'chatwo';
+    const room_chatwo   = 6;
+
+    const sroom_push = 'push';
+    const room_push  = 7;
+
+    const acc_web_type = "web";
+    const acc_native_type = "native";
+    const acc_all_type = "all";
 
 
     //[1,20) 基本的消息

+ 14 - 0
helper/room/room_client.php

@@ -109,4 +109,18 @@ class room_client extends tcp_client
             return $result['data'];
         }
     }
+    public function push($content)
+    {
+        $param = ["act" => 'factory','op' => 'push','content' => $content];
+        $result = $this->request($param);
+        if(empty($result)) return false;
+
+        $code = intval($result['code']);
+        if($code != 200) {
+            return false;
+        }
+        else {
+            return true;
+        }
+    }
 }

+ 57 - 23
helper/room/room_processor.php

@@ -18,12 +18,14 @@ class room_processor implements IProcessor
     private $mAccConnes;
     private $mFactory;
     private $mRooms;
+    private $mChatwo;
 
     public function __construct()
     {
         $this->mAccConnes = [];
         $this->mFactory = new factory();
         $this->mRooms = [];
+        $this->mChatwo = new chatwo();
     }
 
     public function onRequest($bufid, $body)
@@ -37,19 +39,25 @@ class room_processor implements IProcessor
         }
 
         $act = $input['act'];
-        if(!empty($act) && $act == proto_type::act_factory) {
+        if(empty($act)) return false;
+
+        if($act == proto_type::act_factory) {
             $ret = $this->onFactory($bufid,$input);
             room_server::instance()->write($bufid,$ret);
             return true;
         }
-        elseif(!empty($act) && $act == proto_type::act_access) {
+        elseif($act == proto_type::act_access) {
             $ret = $this->onAccess($bufid,$input);
             return $ret;
         }
-        else {
+        elseif($act == proto_type::act_room) {
             $ret = $this->onRoom($bufid,$input);
             return $ret;
         }
+        elseif($act == proto_type::act_chatwo) {
+            $ret = $this->onChatwo($bufid,$input);
+            return $ret;
+        }
     }
 
     public function onClose($bufid)
@@ -149,6 +157,11 @@ class room_processor implements IProcessor
 
             return $this->error(errcode::ErrRoomLeave);
         }
+        elseif($op == 'push') {
+            $content  = $input['content'];
+            $this->write_push($content);
+            return $this->success(NULL);
+        }
         else
         {
             return $this->error(errcode::ErrRoomFactoryOp);
@@ -186,37 +199,58 @@ class room_processor implements IProcessor
         if($room != false)
         {
             $function = $input['op'] . 'Op';
-            $roomkey = $input['room_key'];
-
             if (method_exists($room,$function))
             {
                 $success = $room->$function($input);
                 if($success) {
                     $this->write_roomsg($bufid,$room);
                 }
-                else {
-                    $this->del_user($bufid,$room->room_id(), [$roomkey]);
-                }
                 return true;
             }
         }
 
         return false;
     }
+    ////////////////////////////////////////Peer Message Handler////////////////////////////////////////////////////////
+    private function onChatwo($bufid, $input)
+    {
+        $function = $input['op'] . 'Op';
+        if (method_exists($this->mChatwo,$function))
+        {
+            $msg = $this->mChatwo->$function($input);
+            if($msg != false)
+            {
+                $body = $this->success($msg);
+                foreach ($this->mAccConnes as $conn) {
+                    room_server::instance()->write($conn,$body);
+                }
+            }
 
+            return true;
+        }
+    }
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-    private function del_user($bufid,$room_id,$roomkeys)
+    private function write_push($content)
     {
         $msg = [];
-        $msg['receivers'] = ['type' => 'roomkey', 'users' => $roomkeys];
-        $msg['room'] = $room_id;
-        $msg['act']  = 'room';
-        $msg['op']   = 'deluser';
 
-        $body = $this->success(['msg' => $msg]);
-        room_server::instance()->write($bufid,$body);
-    }
+        $msg['act']  = "room";
+        $msg['op']   = "relay";
+        $msg['relay_type'] = "alluser";
+        $msg['receivers'] = [];
+        $msg['room'] = 0;
+        $msg['receiver_type'] = proto_type::sroom_push;
+
+        $msg['body']['act']  = proto_type::act_push;
+        $msg['body']['op']   = 'message';
+        $msg['body']['content'] = $content;
 
+        $body = $this->success($msg);
+        foreach ($this->mAccConnes as $conn) {
+            room_server::instance()->write($conn,$body);
+        }
+    }
+    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     protected function write_accmsg($bufid,$op,$content)
     {
         $msg['act']  = "access";
@@ -225,7 +259,7 @@ class room_processor implements IProcessor
         $msg['body']['act']  = 'access';
         $msg['body']['op']   = $op;
         $msg['body']['content'] = $content;
-        $body = $this->success(['msg' => $msg]);
+        $body = $this->success($msg);
 
         room_server::instance()->write($bufid,$body);
     }
@@ -234,20 +268,20 @@ class room_processor implements IProcessor
     {
         $retmsgs = $room->return_msgs();
         foreach ($retmsgs as $msg) {
-            $body = $this->success(['msg' => $msg]);
+            $body = $this->success($msg);
             room_server::instance()->write($bufid,$body);
         }
 
         $broad_msgs = $room->broadcast_msgs();
         foreach ($broad_msgs as $msg)
         {
-            $body = $this->success(['msg' => $msg]);
+            $body = $this->success($msg);
             foreach ($this->mAccConnes as $conn) {
                 room_server::instance()->write($conn,$body);
             }
         }
     }
-
+    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     private function room($roomid)
     {
         if($roomid <= 0) return false;
@@ -279,12 +313,12 @@ class room_processor implements IProcessor
         }
         return true;
     }
-    private function success($datas)
+    private function success($val)
     {
         $code = errcode::Success;
         $data['code'] = $code;
         $data['message'] = errcode::msg($code);
-        $data['data'] = $datas;
+        $data['data'] = $val;
 
         return json_encode($data);
     }
@@ -298,7 +332,7 @@ class room_processor implements IProcessor
         $data = array();
         $data['code'] = $code;
         $data['message'] = $message;
-        $data['datas'] = null;
+        $data['data'] = null;
         return json_encode($data);
     }
 }

+ 2 - 1
helper/room_helper.php

@@ -10,7 +10,8 @@ require_once (BASE_ROOT_PATH . '/helper/room/access_client.php');
 require_once (BASE_ROOT_PATH . '/helper/room/proto_type.php');
 require_once (BASE_ROOT_PATH . '/helper/room/base_room.php');
 require_once (BASE_ROOT_PATH . '/helper/room/bargain_room.php');
-require_once (BASE_ROOT_PATH . '/helper/room/chatwo_room.php');
+require_once(BASE_ROOT_PATH . '/helper/room/chat_room.php');
+require_once(BASE_ROOT_PATH . '/helper/room/chatwo.php');
 require_once (BASE_ROOT_PATH . '/helper/room/factory_client.php');
 require_once (BASE_ROOT_PATH . '/helper/room/group_room.php');
 require_once (BASE_ROOT_PATH . '/helper/room/room_client.php');

+ 5 - 2
mobile/control/game.php

@@ -31,7 +31,8 @@ class gameControl extends mbMemberControl
         $result = [];
         if($ret != false) {
             $result['addr'] = $webaddr;
-            $result['token'] = room\author::sign_web($room_id,session_helper::memberid(),room\proto_type::act_shake_bonus);
+            $result['token'] = room\author::sign_web($room_id,session_helper::memberid());
+            $result['room'] = $room_id;
         }
 
         $_SESSION['client_type'] = "wap";
@@ -49,7 +50,9 @@ class gameControl extends mbMemberControl
         $result = [];
         if($ret != false) {
             $result['addr'] = $webaddr;
-            $result['token'] = room\author::sign_web($room_id,session_helper::memberid(),room\proto_type::act_shake_bonus);
+            $result['token'] = room\author::sign_web($room_id,session_helper::memberid());
+            $result['room'] = intval($room_id);
+            $result['user'] = session_helper::memberid();
         }
 
         $_SESSION['client_type'] = "wap";

+ 20 - 0
mobile/control/member_talk.php

@@ -0,0 +1,20 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: stanley-king
+ * Date: 2018/7/12
+ * Time: 上午11:29
+ */
+
+class member_talkControl extends mbMemberControl
+{
+    public function __construct()
+    {
+        parent::__construct();
+    }
+
+    public function authonOp()
+    {
+        
+    }
+}

+ 42 - 12
mobile/templates/default/game/test_shake.php

@@ -9,9 +9,9 @@
 <body>
 <div class="maincontent">
     <input type="text" placeholder="输入内容" id="msg">
-    <button id="send_msg">发送信息</button>
-
-    <button id="shake">摇一摇</button>
+    <input type="text" placeholder="输入内容" id="to_user">
+    <button id="room_msg">房间消息</button>
+    <button id="peer_msg">单点消息</button>
 
     <div class="msg_list"></div>
 </div>
@@ -21,13 +21,18 @@
 <script type="text/javascript">
 
     var token = "<?php echo $output['token']; ?>";
-    var addr = "<?php echo $output['addr']; ?>";
+    var addr  = "<?php echo $output['addr']; ?>";
+    var room  = <?php echo $output['room']; ?>;
+    var user  = <?php echo $output['user']; ?>;
+
+    var seq = 1;
 
     var client = new WebSocket(addr);
     client.onopen = function () {
         var msg = {
             act: 'access',
             op: 'login',
+            seq : seq++,
             token: token
         };
         client.send(JSON.stringify(msg));
@@ -42,29 +47,54 @@
     client.onmessage = function (datas) {
         var msg = datas.data;
         var msgHTML = "<p>" + msg + "</p>";
-        $('.msg_list').append(msgHTML);
+        $('.msg_list').prepend(msgHTML);
+
         console.log(JSON.parse(datas.data));
     };
 
-
-    document.getElementById('send_msg').addEventListener('click', function () {
+    document.getElementById('room_msg').addEventListener('click', function ()
+    {
         var inputVal = $('#msg').val();
         if(!inputVal) {
             return;
         }
+
         var msg = {
-            act: 'access',
-            op: 'login',
-            token: token,
+            act: 'room',
+            op:  'message',
+            seq : seq++,
+            room:room,
+            user:user,
+            type : "text",
             content:inputVal
         };
+
         client.send(JSON.stringify(msg));
     });
 
+    document.getElementById('peer_msg').addEventListener('click', function ()
+    {
+        var inputVal = $('#msg').val();
+        if(!inputVal) {
+            return;
+        }
 
+        var to_user = $('#to_user').val();
+        if(!to_user) {
+            return;
+        }
 
-    document.getElementById('shake').addEventListener('click', function () {
-        client.send('1');
+        var msg = {
+            act: 'chatwo',
+            op:  'message',
+            seq : seq++,
+            from:user,
+            to: to_user,
+            type : "text",
+            content:inputVal
+        };
+
+        client.send(JSON.stringify(msg));
     });
 
 </script>

+ 1 - 0
mobile/util/errcode.php

@@ -96,6 +96,7 @@ class errcode extends SplEnum
     const ErrRoomParam  = 18005;
     const ErrRoomFactoryOp  = 18006;
     const ErrRoomAccessOp  = 18007;
+    const ErrRoomPush  = 18008;
     const ErrAccess = 19000;
 
 

+ 2 - 1
room_factory.php

@@ -15,7 +15,8 @@ require_once(BASE_ROOT_PATH . '/helper/room/factory_processor.php');
 require_once(BASE_ROOT_PATH . '/helper/room/factory_handler.php');
 require_once(BASE_ROOT_PATH . '/helper/room/proto_type.php');
 require_once(BASE_ROOT_PATH . '/helper/room/base_room.php');
-require_once(BASE_ROOT_PATH . '/helper/room/chatwo_room.php');
+require_once(BASE_ROOT_PATH . '/helper/room/chat_room.php');
+require_once(BASE_ROOT_PATH . '/helper/room/chatwo.php');
 require_once(BASE_ROOT_PATH . '/helper/room/group_room.php');
 require_once(BASE_ROOT_PATH . '/helper/room/bargain_room.php');
 require_once(BASE_ROOT_PATH . '/helper/room/factory.php');

+ 2 - 1
room_srv.php

@@ -15,7 +15,8 @@ require_once(BASE_ROOT_PATH . '/helper/room/room_processor.php');
 require_once(BASE_ROOT_PATH . '/helper/room/room_handler.php');
 require_once(BASE_ROOT_PATH . '/helper/room/proto_type.php');
 require_once(BASE_ROOT_PATH . '/helper/room/base_room.php');
-require_once(BASE_ROOT_PATH . '/helper/room/chatwo_room.php');
+require_once(BASE_ROOT_PATH . '/helper/room/chat_room.php');
+require_once(BASE_ROOT_PATH . '/helper/room/chatwo.php');
 require_once(BASE_ROOT_PATH . '/helper/room/group_room.php');
 require_once(BASE_ROOT_PATH . '/helper/room/bargain_room.php');
 require_once(BASE_ROOT_PATH . '/helper/room/factory.php');

+ 6 - 1
test/TestRoomFactory.php

@@ -16,7 +16,8 @@ require_once(BASE_ROOT_PATH . '/helper/room/factory_processor.php');
 require_once(BASE_ROOT_PATH . '/helper/room/factory_handler.php');
 require_once(BASE_ROOT_PATH . '/helper/room/proto_type.php');
 require_once(BASE_ROOT_PATH . '/helper/room/base_room.php');
-require_once(BASE_ROOT_PATH . '/helper/room/chatwo_room.php');
+require_once(BASE_ROOT_PATH . '/helper/room/chat_room.php');
+require_once(BASE_ROOT_PATH . '/helper/room/chatwo.php');
 require_once(BASE_ROOT_PATH . '/helper/room/group_room.php');
 require_once(BASE_ROOT_PATH . '/helper/room/bargain_room.php');
 require_once(BASE_ROOT_PATH . '/helper/room/factory.php');
@@ -98,6 +99,10 @@ class TestRoomFactory extends PHPUnit_Framework_TestCase
     {
         $ret = room\factory_client::instance()->create_shake(self::admin_member_id);
     }
+    public function testPush()
+    {
+        $ret = room\factory_client::instance()->push('hello world');
+    }
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     private function creator($room_id)
     {

+ 26 - 1
test/TestRoomSrv.php

@@ -14,7 +14,8 @@ require_once(BASE_ROOT_PATH . '/helper/room/room_processor.php');
 require_once(BASE_ROOT_PATH . '/helper/room/room_handler.php');
 require_once(BASE_ROOT_PATH . '/helper/room/proto_type.php');
 require_once(BASE_ROOT_PATH . '/helper/room/base_room.php');
-require_once(BASE_ROOT_PATH . '/helper/room/chatwo_room.php');
+require_once(BASE_ROOT_PATH . '/helper/room/chat_room.php');
+require_once(BASE_ROOT_PATH . '/helper/room/chatwo.php');
 require_once(BASE_ROOT_PATH . '/helper/room/group_room.php');
 require_once(BASE_ROOT_PATH . '/helper/room/bargain_room.php');
 require_once(BASE_ROOT_PATH . '/helper/room/factory.php');
@@ -60,6 +61,30 @@ class TestRoomSrv extends PHPUnit_Framework_TestCase
         $ret = $processor->onRequest(0,json_encode(["act" => 'access','op' => 'list']));
     }
 
+    public function testRoomMessage()
+    {
+        $invitee = 36507;
+        $processor = new room\room_processor();
+        $ret = $processor->onRequest(0,json_encode(["act" => 'factory','op' => 'invite','room' => self::room_id,'inviter' => $this->creator(self::room_id),'invitees' => [$invitee]]));
+        $ret = $processor->onRequest(0,json_encode(["act" => 'room','op' => 'message','room' => self::room_id,'user' => $invitee,'type' => 'text','content' => 'xxxxx']));
+    }
+
+    public function testChatwo()
+    {
+        $invitee = 36507;
+        $processor = new room\room_processor();
+        $ret = $processor->onRequest(0,json_encode(["act" => 'chatwo','op' => 'message','seq' => 1,
+                'from' => 36507,'to' => 36429,'type' => 'text','content' => 'hello world']));
+    }
+
+    public function testPush()
+    {
+        $invitee = 36507;
+        $processor = new room\room_processor();
+        $ret = $processor->onRequest(0,json_encode(["act" => 'factory','op' => 'push','seq' => 1,
+            'content' => 'hello world']));
+    }
+
     private function creator($room_id)
     {
         $mod_room = Model('room');