Problem:Adding the SmartClient Simple Chat Application

Hello,

I want to add the Simple Chat Application that is provided in the examples into by project. Here are the things I have done:

  1. Included the module-
<isomorphic:loadISC skin="SmartClient" includeModules="RealtimeMessaging"/>

(My project is in [iso_root] ools\visualBuilder\workspace)
2. Created a window and placed the objects inside the “items” property like-

isc.Window.create({
	ID:"chatWindow",
	visibility:"hidden",
	title:"A Simple Chatting Application by SmartClient",
	animateMinimize:true,
	canDragResize:true,
	canDragReposition:true,
	autoSize:true,
	showMaximizeButton:true,
	showCloseButton:true,
	items:[chatLog,chatForm]

});

(the chatLog and chatForm and two functions are unchanged)

  1. I have also removed the <isomorphic:XML> tags (as I’m developing in JS) and changed the XML code into JS, and have checked the code for syntax errors with no problems.

When the chatWindow.show() function is invoked via a “click” property of a submenu item- nothing happens.

What am I doing wrong? I’ll paste the snippet for convenience.

Thanks

//Isomorphic chat START

isc.Canvas.create({
	autoDraw:false,
	ID:"chatLog",
	left:"50", top:"50",
	width:"500", height:"200",
	overflow:"auto",
	backgroundColor:"white",
	border:"2px solid gray",
	contents:"Chat Session<br>Open this page in multiple client browsers for multi-user chat."
})

isc.DynamicForm.create({
	autoDraw:false,
	ID:"chatForm",
	left:"50", top:"275",

	fields:[
		{	
			name:"user",
			title:"User name",
            required:"true"
		},
		{
			name:"msg",
			title:"Message",
			editorType:"textArea",
			width:"400", height:"50"
		},
		{
			editorType:"button",
			colSpan:"*",
			align:"center",
			title:"Send",
			click:"sendChatMessage()"
		}
	]
})


function sendChatMessage() {
    // Ensure the required 'user' field is not empty
    if (!chatForm.validate()) return;
    
    var userName = chatForm.getValue('user'),
        messageText = chatForm.getValue('msg');

    // If no message was entered, avoid sending an empty message to the server.
    if (!messageText) return;
        
	// assemble the message
	var message =	'<b>' +
					userName +
					':</b> ' +
					messageText +
					'<br><br>';
					
	// and send it to the chatChannel
	Messaging.send('chatChannel', message, "callback(rpcResponse)");
}


function callback(rpcResponse) {
    if (rpcResponse.status != isc.RPCResponse.STATUS_SUCCESS) {
        isc.say("Unable to send message");
    }
}

// receive messages from the chatChannel and add them to the chatLog
Messaging.subscribe("chatChannel", "chatLog.setContents(data + chatLog.contents)");

//Isomorphic chat END

isc.Window.create({
	ID:"chatWindow",
	visibility:"hidden",
	title:"A Simple Chatting Application",
	animateMinimize:true,
	canDragResize:true,
	canDragReposition:true,
	autoSize:true,
	showMaximizeButton:true,
	showCloseButton:true,
	items:[chatLog,chatForm]

});

Hi groovecontrol,

You didn’t actually show the code for the menuItem that shows the Window. Your code looks otherwise fine and a manual call to chatWindow.show() works.