Class: Gs2::Realtime::Client
- Inherits:
-
Core::AbstractClient
- Object
- Core::AbstractClient
- Gs2::Realtime::Client
- Defined in:
- lib/gs2/realtime/Client.rb
Overview
GS2-Realtime クライアント
Constant Summary collapse
- @@ENDPOINT =
'realtime'
Class Method Summary collapse
-
.ENDPOINT(v = nil) ⇒ Object
デバッグ用。通常利用する必要はありません。.
Instance Method Summary collapse
-
#create_gathering(request) ⇒ Array
ギャザリングを作成
ギャザリングを作成すると、ゲームサーバが起動します。
ゲームサーバはWebSocketで接続することができ、同じゲームサーバに接続しているユーザ間でメッセージをやり取りすることができます。
ゲームサーバとの通信プロトコルの説明については別途ドキュメントを確認してください。
userIds にユーザIDを指定することで、ギャザリングに参加できるユーザのIDを制限することができます。
ギャザリング作成時に参加するユーザが確定している場合は指定してください。
省略すると、暗号鍵を知っていれば誰でも参加することができます。
. -
#create_gathering_pool(request) ⇒ Array
ギャザリングプールを作成
GS2-Realtime を利用するには、まずギャザリングプールを作成する必要があります。
ギャザリングプールには複数のギャザリングを紐付けることができます。
. -
#delete_gathering(request) ⇒ Object
ギャザリングを削除.
-
#delete_gathering_pool(request) ⇒ Object
ギャザリングプールを削除.
-
#describe_gathering(request, pageToken = nil, limit = nil) ⇒ Array
ギャザリングリストを取得.
-
#describe_gathering_pool(pageToken = nil, limit = nil) ⇒ Array
ギャザリングプールリストを取得.
-
#get_gathering(request) ⇒ Array
ギャザリングを取得.
-
#get_gathering_pool(request) ⇒ Array
ギャザリングプールを取得.
-
#initialize(region, gs2_client_id, gs2_client_secret) ⇒ Client
constructor
コンストラクタ.
-
#update_gathering_pool(request) ⇒ Array
ギャザリングプールを更新.
Constructor Details
#initialize(region, gs2_client_id, gs2_client_secret) ⇒ Client
コンストラクタ
17 18 19 |
# File 'lib/gs2/realtime/Client.rb', line 17 def initialize(region, gs2_client_id, gs2_client_secret) super(region, gs2_client_id, gs2_client_secret) end |
Class Method Details
.ENDPOINT(v = nil) ⇒ Object
デバッグ用。通常利用する必要はありません。
22 23 24 25 26 27 28 |
# File 'lib/gs2/realtime/Client.rb', line 22 def self.ENDPOINT(v = nil) if v @@ENDPOINT = v else return @@ENDPOINT end end |
Instance Method Details
#create_gathering(request) ⇒ Array
ギャザリングを作成
ギャザリングを作成すると、ゲームサーバが起動します。
ゲームサーバはWebSocketで接続することができ、同じゲームサーバに接続しているユーザ間でメッセージをやり取りすることができます。
ゲームサーバとの通信プロトコルの説明については別途ドキュメントを確認してください。
userIds にユーザIDを指定することで、ギャザリングに参加できるユーザのIDを制限することができます。
ギャザリング作成時に参加するユーザが確定している場合は指定してください。
省略すると、暗号鍵を知っていれば誰でも参加することができます。
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
# File 'lib/gs2/realtime/Client.rb', line 213 def create_gathering(request) if not request; raise ArgumentError.new(); end if not request.has_key?('gatheringPoolName'); raise ArgumentError.new(); end if not request['gatheringPoolName']; raise ArgumentError.new(); end body = {} if request.has_key?('name'); body['name'] = request['name']; end if request.has_key?('userIds') body['userIds'] = request['userIds'] if body['userIds'].is_a?(Array); body['userIds'] = body['userIds'].join(','); end end query = {} return post( 'Gs2Realtime', 'CreateGathering', @@ENDPOINT, '/gatheringPool/' + request['gatheringPoolName'] + '/gathering', body, query); end |
#create_gathering_pool(request) ⇒ Array
ギャザリングプールを作成
GS2-Realtime を利用するには、まずギャザリングプールを作成する必要があります。
ギャザリングプールには複数のギャザリングを紐付けることができます。
70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/gs2/realtime/Client.rb', line 70 def create_gathering_pool(request) if not request; raise ArgumentError.new(); end body = {} if request.has_key?('name'); body['name'] = request['name']; end if request.has_key?('description'); body['description'] = request['description']; end query = {} return post( 'Gs2Realtime', 'CreateGatheringPool', @@ENDPOINT, '/gatheringPool', body, query); end |
#delete_gathering(request) ⇒ Object
ギャザリングを削除
269 270 271 272 273 274 275 276 277 278 279 280 281 282 |
# File 'lib/gs2/realtime/Client.rb', line 269 def delete_gathering(request) if not request; raise ArgumentError.new(); end if not request.has_key?('gatheringPoolName'); raise ArgumentError.new(); end if not request['gatheringPoolName']; raise ArgumentError.new(); end if not request.has_key?('gatheringName'); raise ArgumentError.new(); end if not request['gatheringName']; raise ArgumentError.new(); end query = {} return delete( 'Gs2Realtime', 'DeleteGathering', @@ENDPOINT, '/gatheringPool/' + request['gatheringPoolName'] + '/gathering/' + request['gatheringName'], query); end |
#delete_gathering_pool(request) ⇒ Object
ギャザリングプールを削除
141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/gs2/realtime/Client.rb', line 141 def delete_gathering_pool(request) if not request; raise ArgumentError.new(); end if not request.has_key?('gatheringPoolName'); raise ArgumentError.new(); end if not request['gatheringPoolName']; raise ArgumentError.new(); end query = {} return delete( 'Gs2Realtime', 'DeleteGatheringPool', @@ENDPOINT, '/gatheringPool/' + request['gatheringPoolName'], query); end |
#describe_gathering(request, pageToken = nil, limit = nil) ⇒ Array
ギャザリングリストを取得
173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/gs2/realtime/Client.rb', line 173 def describe_gathering(request, pageToken = nil, limit = nil) if not request; raise ArgumentError.new(); end if not request.has_key?('gatheringPoolName'); raise ArgumentError.new(); end if not request['gatheringPoolName']; raise ArgumentError.new(); end query = {} if pageToken; query['pageToken'] = pageToken; end if limit; query['limit'] = limit; end return get( 'Gs2Realtime', 'DescribeGathering', @@ENDPOINT, '/gatheringPool/' + request['gatheringPoolName'] + '/gathering', query); end |
#describe_gathering_pool(pageToken = nil, limit = nil) ⇒ Array
ギャザリングプールリストを取得
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/gs2/realtime/Client.rb', line 43 def describe_gathering_pool(pageToken = nil, limit = nil) query = {} if pageToken; query['pageToken'] = pageToken; end if limit; query['limit'] = limit; end return get( 'Gs2Realtime', 'DescribeGatheringPool', @@ENDPOINT, '/gatheringPool', query); end |
#get_gathering(request) ⇒ Array
ギャザリングを取得
249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
# File 'lib/gs2/realtime/Client.rb', line 249 def get_gathering(request) if not request; raise ArgumentError.new(); end if not request.has_key?('gatheringPoolName'); raise ArgumentError.new(); end if not request['gatheringPoolName']; raise ArgumentError.new(); end if not request.has_key?('gatheringName'); raise ArgumentError.new(); end if not request['gatheringName']; raise ArgumentError.new(); end query = {} return get( 'Gs2Realtime', 'GetGathering', @@ENDPOINT, '/gatheringPool/' + request['gatheringPoolName'] + '/gathering/' + request['gatheringName'], query); end |
#get_gathering_pool(request) ⇒ Array
ギャザリングプールを取得
96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/gs2/realtime/Client.rb', line 96 def get_gathering_pool(request) if not request; raise ArgumentError.new(); end if not request.has_key?('gatheringPoolName'); raise ArgumentError.new(); end if not request['gatheringPoolName']; raise ArgumentError.new(); end query = {} return get( 'Gs2Realtime', 'GetGatheringPool', @@ENDPOINT, '/gatheringPool/' + request['gatheringPoolName'], query); end |
#update_gathering_pool(request) ⇒ Array
ギャザリングプールを更新
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/gs2/realtime/Client.rb', line 121 def update_gathering_pool(request) if not request; raise ArgumentError.new(); end if not request.has_key?('gatheringPoolName'); raise ArgumentError.new(); end if not request['gatheringPoolName']; raise ArgumentError.new(); end body = {} if request.has_key?('description'); body['description'] = request['description']; end query = {} return put( 'Gs2Realtime', 'UpdateGatheringPool', @@ENDPOINT, '/gatheringPool/' + request['gatheringPoolName'], body, query); end |