blob: 994ca90d69633bfb47d94d864ca62e2ef6d373ff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
// **********************************************************************
//
// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
#pragma once
#include "MainPage.g.h"
#include "ChatView.xaml.h"
#include "LoginView.xaml.h"
#include <Glacier2/Glacier2.h>
#include <Chat.h>
namespace chat
{
struct LoginData
{
std::string hostname;
std::string username;
std::string password;
};
class Coordinator : public Glacier2::SessionCallback, public Demo::ChatCallback
{
public:
Coordinator(Windows::UI::Core::CoreDispatcher^);
void signIn(const LoginData&);
LoginData loginData();
//
// Session callback
//
virtual void createdCommunicator(const Glacier2::SessionHelperPtr&);
virtual void connected(const Glacier2::SessionHelperPtr&);
virtual void disconnected(const Glacier2::SessionHelperPtr&);
virtual void connectFailed(const Glacier2::SessionHelperPtr&, const Ice::Exception&);
//
// Chat callback
//
virtual void message(const std::string& data, const Ice::Current&);
//
// Chat session.
//
void say(const std::string&);
void destroy();
private:
Demo::ChatSessionPrx _chat;
Glacier2::SessionHelperPtr _session;
Windows::UI::Core::CoreDispatcher^ _dispatcher;
LoginData _loginData;
};
typedef IceUtil::Handle<Coordinator> CoordinatorPtr;
public ref class MainPage sealed
{
public:
MainPage();
static MainPage^ instance();
void setConnected(bool c);
void appendMessage(Platform::String^ msg);
private:
virtual void setError(const std::string&);
CoordinatorPtr coordinator()
{
return _coordinator;
}
CoordinatorPtr _coordinator;
static MainPage^ _instance;
friend ref class LoginView;
friend ref class ChatView;
friend class Coordinator;
LoginView^ _loginView;
ChatView^ _chatView;
void signoutClick(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
};
}
|