Ver código fonte

buffer bug fix

walkor 12 anos atrás
pai
commit
3fc10e2156
4 arquivos alterados com 7 adições e 40 exclusões
  1. 2 10
      Config/main.ini
  2. 1 1
      Protocols/Buffer.php
  3. 4 3
      Tests/game.php
  4. 0 26
      Workers/DataCenter.php

+ 2 - 10
Config/main.ini

@@ -16,7 +16,7 @@ socket[port] = 8282
 socket[persistent] = 1
 children_count = 5
 user = www-data
-preread_length = 19
+preread_length = 23
 lan_ip = 127.0.0.1
 game_worker[] = tcp://127.0.0.1:8383
 game_worker[] = tcp://127.0.0.1:8383
@@ -27,15 +27,7 @@ socket[port] = 8383
 socket[persistent] = 1
 children_count = 5
 user = www-data
-preread_length = 19
-
-[DataCenter]
-socket[protocol] = tcp
-socket[port] = 8181
-socket[persistent] = 1
-children_count = 1
-user = www-data
-preread_length = 19
+preread_length = 23
 
 ;监控框架的进程,并提供telnet接口
 [Monitor]

+ 1 - 1
Protocols/Buffer.php

@@ -31,7 +31,7 @@ class Buffer
      * 包头长度
      * @var integer
      */
-    const HEAD_LEN = 19;
+    const HEAD_LEN = 23;
      
     /**
      * 序列号,防止串包

+ 4 - 3
Tests/game.php

@@ -1,13 +1,14 @@
-<?php 
-error_reporting(E_ALL);
+<?php
 ini_set('display_errors', 'on');
+error_reporting(E_ALL);
+define('WORKERMAN_ROOT_DIR', __DIR__.'/../');
 include '../Applications/GameBuffer.php';
 
 $sock = stream_socket_client("tcp://127.0.0.1:8282");
 if(!$sock)exit("can not create sock\n");
 
 $buf = new GameBuffer();
-$buf->body = '123'';
+$buf->body = '123';
 
 fwrite($sock, $buf->getBuffer());
 var_export($ret = fread($sock, 1024));

+ 0 - 26
Workers/DataCenter.php

@@ -1,26 +0,0 @@
-<?php
-/**
- * 
- * 聊天服务器中心节点 负责
- * 1、查询用户在线状态
- * 2、保存用户登录的服务器及通信端口
- * 3、查询用户连接的服务器及通信端口
- * 
- * @author walkor <worker-man@qq.com>
- * 
- */
-require_once WORKERMAN_ROOT_DIR . 'Core/SocketWorker.php';
-require_once WORKERMAN_ROOT_DIR . 'Applications/GameBuffer.php';
-
-class DataCenter extends WORKERMAN\Core\SocketWorker
-{
-    public function dealInput($recv_str)
-    {
-        return GameBuffer::input($recv_str);
-    }
-
-    public function dealProcess($recv_str)
-    {
-        $this->sendToClient($recv_str);
-    }
-}