Commit 4c0c3a0 1 parent 8645747 commit 4c0c3a0 Copy full SHA for 4c0c3a0
File tree 1 file changed +27
-3
lines changed
1 file changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -173,12 +173,36 @@ export class IpcController {
173
173
174
174
const credentials = await sgeService . loginCharacter ( characterName ) ;
175
175
176
- const gameInstance = Game . newInstance ( {
176
+ const gameInstance = await Game . newInstance ( {
177
177
credentials,
178
- dispatch : this . dispatch ,
179
178
} ) ;
180
179
181
- await gameInstance . connect ( ) ;
180
+ const gameStream = await gameInstance . connect ( ) ;
181
+
182
+ this . dispatch ( 'game:connect' , {
183
+ accountName,
184
+ characterName,
185
+ gameCode,
186
+ } ) ;
187
+
188
+ gameStream . subscribe ( {
189
+ next : ( gameEvent ) => {
190
+ const channel = `game:event:${ gameEvent . eventType } ` . toLowerCase ( ) ;
191
+ this . dispatch ( channel , gameEvent ) ;
192
+ } ,
193
+ error : ( error ) => {
194
+ logger . error ( 'game service stream error' , { error } ) ;
195
+ this . dispatch ( 'game:error' , error ) ;
196
+ } ,
197
+ complete : ( ) => {
198
+ logger . info ( 'game service stream completed' ) ;
199
+ this . dispatch ( 'game:disconnect' , {
200
+ accountName,
201
+ characterName,
202
+ gameCode,
203
+ } ) ;
204
+ } ,
205
+ } ) ;
182
206
} ;
183
207
184
208
private sendCommandHandler : IpcInvokeHandler < 'sendCommand' > = async (
You can’t perform that action at this time.
0 commit comments