AutoJoinGroupMulti
Find and join an open group in the pool of groups in multiple group types provided as input arguments.
- isOpenGroup - the isOpenGroup flag is set on group creation, or via the SetGroupOpen method.
AutoJoinStrategy is defined by enum or constant in most of the client libraries. For those that take a string, these are the valid values:
- JoinFirstGroup - Joins the first group found that matches the specified criteria.
- JoinRandomGroup - Finds all groups that matches the specified criteria and then randomly chooses one to join.
Service | Operation |
---|---|
group | AUTO_JOIN_GROUP_MULTI |
Method Parameters
Parameter | Description |
---|---|
groupTypes | The list of group types to draw candidates from |
autoJoinStrategy | Selection strategy to employ when there are multiple matches |
where | Query parameters (optional) |
Usage
http://localhost:3000
- C#
- C++
- Objective-C
- Java
- JavaScript
- Dart
- Cloud Code
- Raw
string[] groupTypes = {"type1","type2"};
AutoJoinStrategy autoJoinStrategy = AutoJoinStrategy.JoinRandomGroup;
string where = "{}";
SuccessCallback successCallback = (response, cbObject) =>
{
Debug.Log(string.Format("Success | {0}", response));
};
FailureCallback failureCallback = (status, code, error, cbObject) =>
{
Debug.Log(string.Format("Failed | {0} {1} {2}", status, code, error));
};
_bc.Group.AutoJoinGroupMulti(groupTypes, autoJoinStrategy, where, successCallback, failureCallback);
const std::vector<std::string> &groupTypes = vector_of_group_types;
eAutoJoinStrategy autoJoinStrategy = eAutoJoinStrategy::JoinFirstGroup;
const char *where = "{}";
_bc->getGroup()->autoJoinGroupMulti(groupTypes, autoJoinStrategy, where, this);
NSArray *groupTypes = @[group_type_array];
AutoJoinStrategy autoJoinStrategy = JoinFirstGroup;
NSString *where = @"{}";
BCCompletionBlock successBlock; // define callback
BCErrorCompletionBlock failureBlock; // define callback
[[_bc groupService]
autoJoinGroupMulti:groupTypes
autoJoinStrategy:autoJoinStrategy
where:where
completionBlock:successBlock
errorCompletionBlock:failureBlock
cbObject:nil];
String[] groupTypes = new String[1];
groupTypes[0] = "type1";
groupTypes[1] = "type2";
AutoJoinStrategy autoJoinStrategy = AutoJoinStrategy.JoinRandomGroup;
String where = "{}";
this; // implements IServerCallback
_bc.getGroup().autoJoinGroupMulti(groupTypes, autoJoinStrategy, where, this);
public void serverCallback(ServiceName serviceName, ServiceOperation serviceOperation, JSONObject jsonData)
{
System.out.print(String.format("Success | %s", jsonData.toString()));
}
public void serverError(ServiceName serviceName, ServiceOperation serviceOperation, int statusCode, int reasonCode, String jsonError)
{
System.out.print(String.format("Failed | %d %d %s", statusCode, reasonCode, jsonError.toString()));
}
var groupTypes = ["type1", "type2"];
var autoJoinStrategy = "JoinRandomGroup";
var where = {};
_bc.group.autoJoinGroupMulti(groupTypes, autoJoinStrategy, where, result =>
{
var status = result.status;
console.log(status + " : " + JSON.stringify(result, null, 2));
});
var groupTypes = ["type1", "type2"];
var autoJoinStrategy = "JoinRandomGroup";
var where = {};
ServerResponse result = await _bc.groupService.autoJoinGroupMulti(groupTypes:groupTypes, autoJoinStrategy:autoJoinStrategy, where:where);
if (result.statusCode == 200) {
print("Success");
} else {
print("Failed ${result.error['status_message'] ?? result.error}");
}
var groupTypes = ["a-group-type-1","a-group-type-2"];
var autoJoinStrategy = "JoinRandomGroup";
var where = {};
var groupProxy = bridge.getGroupServiceProxy();
var postResult = groupProxy.autoJoinGroupMulti(groupTypes, autoJoinStrategy, where);
if (postResult.status == 200) {
// Success!
}
{
"service": "group",
"operation": "AUTO_JOIN_GROUP_MULTI",
"data": {
"groupTypes": ["group_types_array"],
"autoJoinStrategy": "JoinRandomGroup",
"where": {}
}
}
JSON Response
{
"status": 200,
{
"data": {
"groupType": "test",
"groupId": "972e245c-38e8-4ccb-84db-8be5f530a27a",
"memberCount": 3,
"name": "Test2",
"invitedPendingMemberCount": 0,
"requestingPendingMemberCount": 0,
"ownerId": "1b8c0719-6f2e-44a0-95a2-bae46a4c5278",
"summaryData": null,
"isOpenGroup": true
},
}
}