NDEVR
API Documentation
ChatDialog.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: NDEVR
28File: ChatDialog
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#ifdef NDEVR_SUPPORTS_SOCKET_IO
34#include <QMainWindow>
35#include <QListWidget>
36#include <QPlainTextEdit>
37#include <QTimer>
38#include <sio_client.h>
39#include "UsernameDialog.h"
40namespace Ui {
41class ChatDialogUI;
42}
43
44using namespace sio;
45namespace NDEVR
46{
50 class ChatDialog : public QWidget
51 {
52 Q_OBJECT
53
54 public:
59 explicit ChatDialog(QWidget *parent = 0);
63 ~ChatDialog();
64
65 public Q_SLOTS:
69 void SendBtnClicked();
73 void TypingChanged();
77 void OnMessageReturn();
78 protected:
83 void showEvent(QShowEvent* event);
84
85 Q_SIGNALS:
90 void RequestAddListItem(QListWidgetItem *item);
95 void RequestRemoveListItem(QListWidgetItem *item);
100 void RequestToggleInputs(bool loginOrNot);
101 private Q_SLOTS:
106 void AddListItem(QListWidgetItem *item);
111 void RemoveListItem(QListWidgetItem *item);
116 void ToggleInputs(bool loginOrNot);
120 void TypingStop();
124 void NicknameAccept();
128 void NicknameCancelled();
129 private:
137 void OnNewMessage(std::string const& name, message::ptr const& data, bool hasAck, message::list &ack_resp);
145 void OnUserJoined(std::string const& name, message::ptr const& data, bool hasAck, message::list &ack_resp);
153 void OnUserLeft(std::string const& name, message::ptr const& data, bool hasAck, message::list &ack_resp);
161 void OnTyping(std::string const& name, message::ptr const& data, bool hasAck, message::list &ack_resp);
169 void OnStopTyping(std::string const& name, message::ptr const& data, bool hasAck, message::list &ack_resp);
177 void OnLogin(std::string const& name, message::ptr const& data, bool hasAck, message::list &ack_resp);
182 void OnConnected(std::string const& nsp);
187 void OnClosed(client::close_reason const& reason);
191 void OnFailed();
195 void ShowLoginDialog();
196
197 Ui::ChatDialogUI *ui;
198
199 std::unique_ptr<client> _io;
200
201 std::unique_ptr<UsernameDialog> m_dialog;
202
203 QString m_name;
204
205 std::unique_ptr<QTimer> m_timer;
206
207 QListWidgetItem *m_typingItem;
208 };
209
210}
211#endif
212
The primary namespace for the NDEVR SDK.