1 / 28

EAS306 Building a Chat Server with EAServer and PowerBuilder

EAS306 Building a Chat Server with EAServer and PowerBuilder. Dean Jones [TeamSybase] CEO of PowerObjects dean@powerobjects.com (612) 339-3355. Who We Are…. PowerObjects Multi-Million dollar consulting company Sybase Consulting Partner Value Added reseller Premier consulting partner

arin
Download Presentation

EAS306 Building a Chat Server with EAServer and PowerBuilder

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. EAS306 Building a Chat Server with EAServer and PowerBuilder Dean Jones [TeamSybase]CEO of PowerObjects dean@powerobjects.com(612) 339-3355

  2. Who We Are… • PowerObjects • Multi-Million dollar consulting company • Sybase Consulting Partner • Value Added reseller • Premier consulting partner • Custom Solution Provider • Specialize in EAServer and Web Development • Offer Web application hosting • Certified Developers staff • PowerBuilder, Java and Microsoft Certifies • Member of Team Sybase

  3. Overview • Building a Chat server using PowerBuilder and EAServer • Using Java Message Service • Publishing Messages • Subscribing to Messages • PowerBuilder Components • Pushed messages onMessage Event • Taking it one step further

  4. Message Service • EAServer’s message service provides a powerful means by which to leverage multiple threads in your distributed applications

  5. Message Service • The message service provides queues for message consumers • Allows message producers to send messages to specified queues (point-to-point messaging) • Publish messages with specified topics that may be of interest to registered consumers (publish/subscribe messaging) • There are two parts to the message service • A Publisher • A Consumer

  6. Message Producer EAServer Client or Component MessageService Proxy Message Consumer MessageServer Publish MessageTopic MessageQueue MessageQueue Client or Component onMessage Notify MessageQueue Message Service

  7. Publishing Messages • To publish a message, there are three steps: • Create a proxy for message service • Populate the message • Publish

  8. PowerBuilder Proxy • Before you can send a message to the queue you must generate MessageService Proxy • NOTE: The objects created will have an issue with wchar • To fix you must edit the source and replace wchar data type with String data type

  9. Populate the Message • A message is a structure of information to send to the server

  10. Publish • Publish a message with the specified message topic. • A copy of this message will be sent to the queues for all consumers who have registered a message selector that returns TRUE when applied to this message void publish ( in string topic, in CtsComponents::Message msg, in long options );

  11. Chat Application • You type a message into a single line edit and send when the user clicks Send.

  12. ctscomponents_message msg ctscomponents_property prop ctscomponents_propertyvalue val val = create ctscomponents_propertyvalue val.stringValue( sle_message.text ) prop.value = val msg.text = sle_name.text + ": "+ sle_message.text msg.props[1] = prop msg.key = ims.getMessageKey() msg.replyTo = "" ims.publish( "chat", msg, 0 ) sle_message.text = "" sle_message.SetFocus() Chat Application

  13. Consuming Messages • To retrieve messages, there are two options: • First is to pull messages from a given queue • Second option is to let the message service push messages • EAServer cannot push messages to a PowerBuilder client application, it can only push messages to PowerBuilder component • EAServer can push messages to a Java client

  14. Consuming Messages • Consumers of messages can either pull messages or have them pushed. There are three steps to pulling messages: • Connect to the Message Service • Specify a Queue and a Topic • Receive messages • To be a consumer of pushed messages, three steps must be taken: • Implement Message Listener • Code the onMessage event • Register the receiving component using code or message service manager

  15. Connect to Message Service ctsComponents_MessageService cms ctscomponents_messageseq cseq ctscomponents_messagequeue cmsg ctscomponents_message cm ctscomponents_messagekey after string sz_queue int i connection c c = CREATE connection c.application = "" c.location = "iiop://jones-dean:9000" c.userid = "jagadmin" c.password = "sarah" c.driver = "jaguar" c.ConnectToServer() c.CreateInstance(cms, "CtsComponents/MessageService")

  16. Receive Messages sz_queue = cms.getUniqueName(1) cmsg = cms.getMessageQueue(sz_queue,"",0) cms.addselector(sz_queue, "topic='chat'" ) do while 1 < 2 //CtsComponents_Messageseq seq cseq = cmsg.receive( 0, 30 ) For i = 1 to UpperBound(cseq.item) cm = cseq.item[i] arg_notify.post of_notify( cm.Text ) after = cm.key Next loop return 1

  17. Multi-Threading in PowerBuilder

  18. Pushed Messages • Receiving messages that are pushed from the message service’s receive() method is straightforward. • Code a component with an onmessage() method with the following signature: Return [none] onmessage( ctscomponents_message msg )

  19. Pushed Messages • You can create a new component and add the onmessage() method or you can create a component that implements an existing interface • In this example, we’ll add logic to the onmessage() method that writes to the log and indicates when the component is called

  20. Pushed Messages • It’s important to note that if you code a custom component that does not implement CstComponent/MessageListener, you must add this interface to your component using Jaguar Manager (Figure 12). The custom interface has the component’s actual IDL; you must add the MessageListener IDL

  21. Pushed Messages • After creating and deploying the component, you must go into Jaguar Manager and configure the message queue to listen for messages. Under Message Service you can configure a new queue. Do this by right clicking on Configured Queues and selecting New.

  22. Message flow n_messagelistener Push Messages MessageService EAServer Client Side Chat Client I Chat Client II Publish Message Pull Messages

  23. Taking it one Step Further • Keeping track of who’s connected • Sending messages to selected users • Receiving messages from selected users

  24. New Getting more Help • Mentoring • New PowerBuilder 9 Book • Internet and Distributed Application Development • EAServer API Interface • EAServer on-line help • Forums

  25. New Getting more Help • Sybase Tools Seminar April 2004 • Minneapolis, MN • Over 150 Attendees • Six Sessions • Panel Discussion with all experts and Sybase product managers • http://www.powerobjects.com/seminar

  26. Questions

  27. Contact PowerObjects • Send E-mail and Questions: • dean@powerobjects.com • Visit our Web-site: • www.powerobjects.com • Call Us: • Office (612) 339-3355

  28. Grab one of my business card Dean JonesChief Executive Officerwww.powerobjects.com 401 2nd Ave. S. Suite 843Minneapolis, MN 55401Office 612.339.3355cell 612.701.4017fax 612.339.4433 dean@powerobjects.com

More Related