|
Project Information
Members
Links
|
What is it?Bot Platform lets you create your own robot with your favorite developing languages and environments, such as JAVA C# C++ VB and so on. The SDK is easy to distribute, develop, debug and deploy. Developers can devote their energies to the robot itself, without taking care of the complex communication protocol. The SDK supports almost all the Messenger features, including user file, custom emoticon, nudge, etc. An integrated activity window is also provided in this SDK, so that developers can send user a web page with rich contents in the right activity window. DocumentationDiscussionQuick ExampleJava Example: RobotServerFactory serverFactory = RobotServerFactory.getInstance();
final RobotServer server = serverFactory.createRobotServer("server.botplatform.com", 6602);
server.setReconnectedSupport(true);
server.setRobotHandler(new RobotAdapter(){
public void messageReceived(RobotSession session,
RobotMessage message) {
session.send("Hello World!");
System.out.println(message.getString());
}
});
server.login("you spid", "your sppwd");
Runtime.getRuntime().addShutdownHook(new Thread(){
public void run(){
server.logout();
}
});
C# Example: static void server_MessageReceived(IRobotSession session, IRobotMessage message)
{
session.SendText("Hello World!");
Console.WriteLine(message.Text);
}
static void Main(string[] args)
{
RobotServerFactory serverFactory = new RobotServerFactory();
serverFactory.Init(2);
RobotServer server = serverFactory.CreateRobotServer("server.botplatform.com", 6602);
server.MessageReceived += new _IRobotServerEvents_MessageReceivedEventHandler(server_MessageReceived);
server.Login("your sppid", "your sppwd", 60000);
string cmd = null;
while ((cmd = Console.ReadLine()) != null)
if (cmd.Equals("exit")) break;
server.Logout();
serverFactory.Destroy();
}
C++ Example: _ATL_FUNC_INFO s_info_onMessageReceived = { CC_STDCALL, VT_EMPTY, 2, { VT_UNKNOWN, VT_UNKNOWN } };
class RobotServerEventsImpl : public IDispEventSimpleImpl<1, RobotServerEventsImpl, &DIID__IRobotServerEvents>
{
public:
BEGIN_SINK_MAP(RobotServerEventsImpl)
SINK_ENTRY_INFO(1, DIID__IRobotServerEvents, 3, &RobotServerEventsImpl::onMessageReceived, &s_info_onMessageReceived)
END_SINK_MAP()
VB Example: Sub MessageReceived(ByVal session As IRobotSession, ByVal message As IRobotMessage)
session.SendText("Hello World!")
Console.WriteLine(message.Text)
End Sub
<MTAThread()> Sub Main()
Dim robotServerFactory As RobotServerFactory = New RobotServerFactory robotServerFactory.Init(2)
For a more complete example, see the tutorials. |