KradekMFC / MFCSocket

Module for communicating with MFC chat servers
MIT License
3 stars 2 forks source link

Basic example of how to use #3

Closed Shmee closed 9 years ago

Shmee commented 9 years ago

Would this be used to connect to log chat rooms? If so, is there a basic example of how to use this?

KradekMFC commented 9 years ago

@vasive Yes you can. I'll put together a small example when I get a chance.

KradekMFC commented 9 years ago

This snippet connects to MFC, joins a room and starts logging out chat messages to the console. Replace with the id of the model whose room you want to join.

var MFCSocket = require("MFCSocket");
var MessageType = require('MFCSocket').MFCMessageType;
var JoinChannelMessage = require("MFCSocket").JoinChannelMessage;

var socket = new MFCSocket();
socket.on("loggedIn", function(u){
    socket.send(new JoinChannelMessage(u.SessionId, <model broadcasterId>));    
});
socket.on("mfcMessage", function(msg){
    if (msg.Type == MessageType.FCTYPE_CMESG)
        console.log(msg.Data.nm, msg.Data.msg);
});
Shmee commented 9 years ago

Thanks! this helps a bunch!