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
|
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
|
of_log(@"Error logging in: %@", exception);
[OFApplication terminateWithStatus: 1];
}
_client = [client retain];
of_log(@"Logged in client: %@", _client);
[self sync];
}];
}
- (void)sync
{
[_client syncWithTimeout: 5
[_client startSyncLoop];
block: ^ (id exception) {
if (exception != nil) {
of_log(@"Failed to sync: %@", exception);
[OFApplication terminateWithStatus: 1];
}
of_log(@"Synced");
[self fetchRoomList];
}];
}
- (void)fetchRoomList
{
[_client fetchRoomListWithBlock: ^ (OFArray<OFString *> *rooms,
|
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
+
+
+
|
of_log(@"Failed to join room %@: %@", room, exception);
[OFApplication terminateWithStatus: 1];
}
_roomID = [roomID copy];
of_log(@"Joined room %@", _roomID);
[self sync2];
}];
}
- (void)sync2
{
[_client syncWithTimeout: 5
block: ^ (id exception) {
if (exception != nil) {
of_log(@"Failed to sync: %@", exception);
[OFApplication terminateWithStatus: 1];
}
of_log(@"Synced");
[self sendMessage];
}];
}
- (void)sendMessage
{
[_client sendMessage: @"ObjMatrix test successful!"
roomID: _roomID
block: ^ (id exception) {
if (exception != nil) {
of_log(@"Failed to send message to room %@: %@",
_roomID, exception);
[OFApplication terminateWithStatus: 1];
}
of_log(@"Message sent to %@", _roomID);
of_log(
@"Waiting 5 seconds before leaving room and logging out");
[self leaveRoom];
[self performSelector: @selector(leaveRoom)
afterDelay: 5];
}];
}
- (void)leaveRoom
{
[_client leaveRoom: _roomID
block: ^ (id exception) {
|