Skip to content

Commit

Permalink
Merge pull request #6 from CrystSw/develop
Browse files Browse the repository at this point in the history
バージョン1.1.3のmasterへの統合
  • Loading branch information
CrystSw authored Mar 31, 2020
2 parents 0f226dd + c2950ec commit 4d28407
Show file tree
Hide file tree
Showing 7 changed files with 288 additions and 133 deletions.
231 changes: 103 additions & 128 deletions src/corefiles/OlinvasCore.php

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/corefiles/OlinvasLoadManager.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
require_once 'OlinvasCore.php';
require_once 'Logger.php';
require_once 'Logger.php';
require_once 'RoomInfo.php';
?>
175 changes: 175 additions & 0 deletions src/corefiles/RoomInfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
<?php
namespace Olinvas;

class RoomInfo {

private $host; //ルームホストのコネクション
private $name; //ルーム名
private $password; //ルームパスワード
private $friendKey; //フレンドキー
private $history; //History
private $historyNum; //History数
private $tmpHistory; //仮History
private $tmpHistoryNum; //仮History数

private $member; //メンバ
private $friendMember; //フレンドメンバ
private $memberNum; //ルームメンバ数
private $memberId; //メンバID
private $checkPoint; //HistoryのCheckPointデータ(Base64画像)
private $checkPointRequest; //CheckPoint要求中か?

public function __construct($host, $roomName, $roomPassword) {
$this->host = $host;
$this->name = $roomName;
$this->password = $roomPassword;
$this->friendKey = base64_encode(openssl_random_pseudo_bytes(6));
$this->member = [];
$this->friendMember = [];
$this->memberNum = 0;
$this->memberId = [];
$this->history = [];
$this->historyNum = 0;
$this->tmpHistory = [];
$this->tmpHistoryNum = 0;
$this->checkPoint = null;
$this->checkPointRequest = false;
}

//ホストを取得
public function getHost(){
return $this->host;
}

//ホストメンバかどうか
public function isHostMember($conn){
return $this->host->resourceId === $conn->resourceId;
}

//ルーム名を取得
public function getName(){
return $this->name;
}

//ルームパスワードを取得
public function getPassword(){
return $this->password;
}

//フレンドキーを取得
public function getFriendKey(){
return $this->friendKey;
}

//Historyを取得
//Historyの内容を改変する場合は,以下のresetHistory, registHistoryを用いてください.
public function getHistory(){
return $this->history;
}

//History数を取得
//Historyの内容を改変する場合は,以下のresetHistory, registHistoryを用いてください.
public function getHistoryNum(){
return $this->historyNum;
}

//Historyの登録
public function registHistory(string $history){
$this->history[] = $history;
++$this->historyNum;
}

//Historyのリセット
public function resetHistory(){
$this->history = [];
$this->historyNum = 0;
}

//仮Historyを取得
//仮Historyの内容を改変する場合は,以下のresetTmpHistory, registTmpHistoryを用いてください.
public function getTmpHistory(){
return $this->tmpHistory;
}

//仮History数を取得
//仮Historyの内容を改変する場合は,以下のresetTmpHistory, registTmpHistoryを用いてください.
public function getTmpHistoryNum(){
return $this->tmpHistoryNum;
}

//仮Historyの登録
public function registTmpHistory(string $history){
$this->tmpHistory[] = $history;
++$this->tmpHistoryNum;
}

//仮Historyのリセット
public function resetTmpHistory(){
$this->tmpHistory = [];
$this->tmpHistoryNum = 0;
}

//メンバ情報を取得
public function getMember(){
return $this->member;
}

//メンバ登録
public function registMember($conn){
//ルームメンバにホストを追加
$this->member[$this->memberNum] = $conn;
//ホストのルームメンバIDを登録(ルーム退室時に利用)
$this->memberId[$conn->resourceId] = $this->memberNum;
//ルームメンバ数のインクリメント
++$this->memberNum;
}

//メンバ解除
public function unregistMember($conn){
//ルームメンバから抜ける
unset($this->member[$this->memberId[$conn->resourceId]]);
--$this->memberNum;

//フレンドメンバだった場合,そちらも解除
if(isset($this->friendMember[$conn->resourceId])){
unset($this->friendMember[$conn->resourceId]);
}
}

//フレンドメンバかどうか
public function isFriendMember($conn){
return isset($this->friendMember[$conn->resourceId]);
}

//フレンドメンバ登録
public function registFriendMember($conn){
//ルームメンバにホストを追加
$this->friendMember[$conn->resourceId] = true;
}

//メンバ数を取得
public function getMemberNum(){
return $this->memberNum;
}

//チェックポイントを取得
public function getCheckPoint(){
return $this->checkPoint;
}

//チェックポイントを設定
public function setCheckPoint($checkPoint){
$this->checkPoint = $checkPoint;
}

//チェックポイント要求中かどうか
public function isCheckPointRequest(){
return $this->checkPointRequest;
}

//チェックポイント要求中フラグ
public function setCheckPointRequest($bool){
$this->checkPointRequest = $bool;
}
}
?>
2 changes: 1 addition & 1 deletion src/olinvas_websocket_server.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
//ロガーの初期化
$GLOBALS['logger'] = new Logger(LOG_TYPE, LOG_OUTPUT_DIRECTORY);
$GLOBALS['logger']->printLog(LOG_INFO, "###Olinvas websocket server has started.###");
$GLOBALS['logger']->printLog(LOG_INFO, "###Server Version: 1.1.2 (for Client Version: 1.1.2)###");
$GLOBALS['logger']->printLog(LOG_INFO, "###Server Version: 1.1.3 (for Client Version: 1.1.3)###");
$GLOBALS['logger']->printLog(LOG_INFO, "###Protocol Version: 1.1###");

//サーバスタートアップ
Expand Down
2 changes: 1 addition & 1 deletion webroot/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ <h2 class="text-center">Olinvasを使ってみよう.</h2>
</div>
</div>
<footer class="fixed-bottom bg-primary text-white">
Olinvas ver.1.1.2 (c) 2020 CrystSw
Olinvas ver.1.1.3 (c) 2020 CrystSw
</footer>
</body>
</html>
2 changes: 1 addition & 1 deletion webroot/js/olinvas.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*==============================
Olinvas Client
--------------------------------
client ver.1.1.2
client ver.1.1.3
protocol ver.1.1
==============================*/

Expand Down
6 changes: 5 additions & 1 deletion webroot/room.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ <h1 id="room-name"role="none"></h1>
<div id="sminfo_server-response-join" class="text-danger m-2"></div>
<button type="button" class="btn btn-info btn-sm" onclick="$(this).olinvas_client('joinRoom', getParam('id'), $('#rm_join-rpass').val())">参加</button>
</div>
<hr/>
<div class="text-center">
<a class="mt-3" href="./room.html">ルームを作成するにはここをクリック</a>
</div>
</div>
</div>
<div id="rm_create-room">
Expand Down Expand Up @@ -179,7 +183,7 @@ <h1 id="room-name"role="none"></h1>
</div>
</div>
<footer class="fixed-bottom bg-primary text-white">
Olinvas ver.1.1.2 (c) 2020 CrystSw
Olinvas ver.1.1.3 (c) 2020 CrystSw
</footer>
</body>
</html>

0 comments on commit 4d28407

Please sign in to comment.