SendTeamChatMessageRequest
Send a message to all the players who are member of the given team
View interactive version here
Request Parameters
Parameter |
Required |
Type |
Description |
message |
No |
string |
The message to send |
ownerId |
No |
string |
The team owner to find, used in combination with teamType. If not supplied the current players id will be used |
teamId |
No |
string |
The teamId to find (may be null if teamType supplied) |
teamType |
No |
string |
The teamType to find, used in combination with the current player, or the player defined by ownerId |
Response Parameters
A response to a send team message request.
Parameter |
Type |
Description |
scriptData |
ScriptData |
A JSON Map of any data added either to the Request or the Response by your Cloud Code |
Nested types
ScriptData
A collection of arbitrary data that can be added to a message via a Cloud Code script.
Parameter |
Type |
Description |
myKey |
string |
An arbitrary data key |
myValue |
JSON |
An arbitrary data value. |
Error Codes
Key |
Value |
Description |
team |
INVALID |
No team exists for the given details |
team |
NOT_A_MEMBER |
The current player is not a member of the team they are trying to message |
authentication |
NOTAUTHORIZED |
The player is not authorized to perform the request |
teamId|teamType |
REQUIRED |
The teamId or teamType is required but not provided |
Code Samples
C#
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;
...
new SendTeamChatMessageRequest()
.SetMessage(message)
.SetOwnerId(ownerId)
.SetTeamId(teamId)
.SetTeamType(teamType)
.Send((response) => {
GSData scriptData = response.ScriptData;
});
ActionScript 3
import com.gamesparks.*;
import com.gamesparks.api.requests.*;
import com.gamesparks.api.responses.*;
import com.gamesparks.api.types.*;
...
gs.getRequestBuilder()
.createSendTeamChatMessageRequest()
.setMessage(message)
.setOwnerId(ownerId)
.setTeamId(teamId)
.setTeamType(teamType)
.send(function(response:com.gamesparks.api.responses.SendTeamChatMessageResponse):void {
var scriptData:ScriptData = response.getScriptData();
});
Objective-C
...
GSSendTeamChatMessageRequest* request = [[GSSendTeamChatMessageRequest alloc] init]
[request setMessage:message
[request setOwnerId:ownerId
[request setTeamId:teamId
[request setTeamType:teamType
[request setCallback:^ (GSSendTeamChatMessageResponse* response) {
NSDictionary* scriptData = [response getScriptData]
}]
[gs send:request]
C++
#include <GameSparks/generated/GSRequests.h>
using namespace GameSparks::Core;
using namespace GameSparks::Api::Responses;
using namespace GameSparks::Api::Requests;
...
void SendTeamChatMessageRequest_Response(GS& gsInstance, const SendTeamChatMessageResponse& response) {
GSData scriptData = response.getScriptData();
}
......
SendTeamChatMessageRequest request(gsInstance);
request.SetMessage(message)
request.SetOwnerId(ownerId)
request.SetTeamId(teamId)
request.SetTeamType(teamType)
request.Send(SendTeamChatMessageRequest_Response);
Java
import com.gamesparks.sdk.api.autogen.GSRequestBuilder.SendTeamChatMessageRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.SendTeamChatMessageResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;
...
gs.getRequestBuilder().createSendTeamChatMessageRequest()
.setMessage(message)
.setOwnerId(ownerId)
.setTeamId(teamId)
.setTeamType(teamType)
.send(new GSEventListener<SendTeamChatMessageResponse>() {
@Override
public void onEvent(SendTeamChatMessageResponse response) {
}
});
Cloud Code
var request = new SparkRequests.SendTeamChatMessageRequest();
request.message = ...;
request.ownerId = ...;
request.teamId = ...;
request.teamType = ...;
var response = request.Send();
var scriptData = response.scriptData;