跳到主要内容

notify_client

简介

作为客户端接入通知服务器notify server

本pkg用于创建连接notify server的客户端连接对象;

一般的,只有作为notify server的客户端才需要本pkg;

目前notify server的客户只有social server;

组件接口

NotifyClient.gs

处理notify server连接的对象

本对象包含组件:request_client

函数原型函数作用
bool ping()检查目标主机是否可用

notify_client.gs

函数原型函数作用
object create_client(map para)创建一个连接notify server的客户端连接对象

样例

import pkg.notify_client;

public void sample()
{
queue q = queue.create("");
map para = {
"ip" : "127.0.0.1", // notify server的ip
"port" : 8421, // notfiy server的port
"token" : "NSTK1871511198", // 连接时使用的身份令牌
"info" : { // notify server要求提供的一些信息
"id" : "social_server1", // 连接者的id
"ip" : "127.0.0.1", // 连接者的ip
"port" : 8431, // 连接者的服务端口
},
"port_recv_size" : 262144, // 接收缓冲区大小,这里设置为256K
"cookieless_msg_queue" : q, // 来自notify server的通知消息的接收队列
"auth_success_callback" : (: when_auth_success :),
};
object client = notify_client.create_client(para);
client.ping();
}

void when_auth_success()
{
printf("Establish connection to notify server successful.\n");
}