~ubuntu-branches/ubuntu/quantal/zeroc-ice/quantal

« back to all changes in this revision

Viewing changes to demo/Glacier2/chat/Client.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Francisco Moya
  • Date: 2006-08-06 19:00:57 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060806190057-3q4p9ws4ucyamn10
Tags: 3.1.0-2
* Patches #5 to #6 from ZeroC forums.
* Patch by Michael Pugach for DescriptorHelper.cpp.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// **********************************************************************
2
2
//
3
 
// Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved.
 
3
// Copyright (c) 2003-2006 ZeroC, Inc. All rights reserved.
4
4
//
5
5
// This copy of Ice is licensed to you under the terms described in the
6
6
// ICE_LICENSE file included in this distribution.
18
18
{
19
19
public:
20
20
 
21
 
    SessionPingThread(const Glacier2::SessionPrx& session) :
 
21
    SessionPingThread(const Glacier2::SessionPrx& session, long timeout) :
22
22
        _session(session),
23
 
        _timeout(IceUtil::Time::seconds(20)),
 
23
        _timeout(IceUtil::Time::seconds(timeout)),
24
24
        _destroy(false)
25
25
    {
26
26
    }
70
70
    virtual void
71
71
    message(const string& data, const Ice::Current&)
72
72
    {
 
73
#ifdef __xlC__
 
74
 
 
75
        //
 
76
        // The xlC compiler synchronizes cin and cout; to see the messages
 
77
        // while accepting input through cin, we have to print the messages
 
78
        // with printf
 
79
        //
 
80
 
 
81
        printf("%s\n", data.c_str());
 
82
        fflush(0);
 
83
#else
73
84
        cout << data << endl;
 
85
#endif
74
86
    }
75
87
};
76
88
 
123
135
            }
124
136
        }
125
137
 
126
 
        SessionPingThreadPtr ping = new SessionPingThread(session);
 
138
        SessionPingThreadPtr ping = new SessionPingThread(session, (long)router->getSessionTimeout() / 2);
127
139
        ping->start();
128
140
 
129
 
        string category = router->getServerProxy()->ice_getIdentity().category;
130
141
        Ice::Identity callbackReceiverIdent;
131
142
        callbackReceiverIdent.name = "callbackReceiver";
132
 
        callbackReceiverIdent.category = category;
 
143
        callbackReceiverIdent.category = router->getCategoryForClient();
133
144
 
134
145
        Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Chat.Client");
135
146
        ChatCallbackPrx callback = ChatCallbackPrx::uncheckedCast(
165
176
                }
166
177
            }
167
178
            while(cin.good());
168
 
            router->destroySession();
 
179
 
 
180
            try
 
181
            {
 
182
                router->destroySession();
 
183
            }
 
184
            catch(const Ice::ConnectionLostException&)
 
185
            {
 
186
                //
 
187
                // Expected: the router closed the connection.
 
188
                //
 
189
            }
169
190
        }
170
191
        catch(const Ice::Exception& ex)
171
192
        {
208
229
main(int argc, char* argv[])
209
230
{
210
231
    ChatClient app;
211
 
    return app.main(argc, argv, "config");
 
232
    return app.main(argc, argv, "config.client");
212
233
}