Skip to main content

Query Channel List

Explains two methods for querying the channel list.

WebSocket Method​

Query the list of currently available channels via WebSocket.

Method Information​

ItemContent
MethodChatManager.Instance.GetChannels()
CallbackOnChannels(ChatChannelInfo[] channels)

ChatChannelInfo​

FieldTypeDescription
channelstringChannel name
countintNumber of users

Usage Example​

using UnityEngine;

public class ChatExample : MonoBehaviour, IChatListener
{
public void GetChannels()
{
ChatManager.Instance.GetChannels();
}

public void OnChannels(ChatChannelInfo[] channels)
{
foreach (var channel in channels)
Debug.Log($"Channel: {channel.channel}, Users: {channel.count}");
}

// ... Other IChatListener method implementations
}

REST API Method​

Available Before Socket Connection

The REST API method can be used before WebSocket connection. Use this method if you want to query the channel list before connecting to the chat server.

URL Verification

This API uses the service-api.playnanoo.com domain.

API Information​

  • URL: https://service-api.playnanoo.com/chat/v20221201/channels
  • Method: GET
  • Authentication Required: No

Request Parameters​

The Req class inherits from DeviceInfo.

No additional parameters required.

Response Data​

Res​

FieldTypeDescription
ItemsList<ChatChannelInfo>Channel list

ChatChannelInfo​

FieldTypeDescription
channelstringChannel name
countintNumber of users

Unity C# Implementation​

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.Networking;

public class Channles
{
static string path = "https://service-api.playnanoo.com/chat/v20221201/channels";

[Serializable]
public class Req : DeviceInfo
{
public IEnumerator Send(Action<Res> onSuccess, Action<BaseResponse> onError)
{
yield return HttpClient.Send<Req, Res>(
UnityWebRequest.kHttpVerbGET,
path,
requireToken: false,
body: this,
onSuccess: onSuccess,
onError: onError
);
}
}

[Serializable]
public class Res : BaseResponse
{
public List<ChatChannelInfo> Items;
}

[Serializable]
public class ChatChannelInfo
{
public string channel;
public int count;
}
}

Usage Example​

using UnityEngine;

public class ChatExample : MonoBehaviour
{
public void GetChannelList()
{
Channles.Req req = new Channles.Req();
StartCoroutine(req.Send(
onSuccess: res =>
{
foreach(Channles.ChatChannelInfo item in res.Items)
{
Debug.Log($"Channel : {item.channel}");
Debug.Log($"Count : {item.count}");
}
},
onError: (error) =>
{
Debug.LogError($"GetChannelList failed: [{error.ErrorCode}] {error.Message}");
}
));
}
}