fix(core): update
This commit is contained in:
		
							
								
								
									
										15
									
								
								test/test.ts
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								test/test.ts
									
									
									
									
									
								
							| @@ -69,9 +69,22 @@ tap.test('a second client should be able to subscibe', async () => { | |||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   testClientUniverse2.addChannel(testChannelData.channelName, testChannelData.channelPass); |   testClientUniverse2.addChannel(testChannelData.channelName, testChannelData.channelPass); | ||||||
|  |   await testClientUniverse2.start(); | ||||||
| }); | }); | ||||||
|  |  | ||||||
| tap.test('should receive a message correctly', async () => {}); | tap.test('should receive a message correctly', async (tools) => { | ||||||
|  |   const done = tools.defer(); | ||||||
|  |   const testChannel = testClientUniverse.getChannel(testChannelData.channelName); | ||||||
|  |   const testChannel2 = testClientUniverse2.getChannel(testChannelData.channelName); | ||||||
|  |   const subscription = await testChannel2.subscribe(messageArg => { | ||||||
|  |     console.log('Yay##########'); | ||||||
|  |     done.resolve(); | ||||||
|  |   }); | ||||||
|  |   await testChannel.sendMessage({ | ||||||
|  |     messageText: 'hellothere' | ||||||
|  |   }); | ||||||
|  |   await done.promise; | ||||||
|  | }); | ||||||
|  |  | ||||||
| tap.test('should disconnect the client correctly', async () => { | tap.test('should disconnect the client correctly', async () => { | ||||||
|   await testClientUniverse.stop(); |   await testClientUniverse.stop(); | ||||||
|   | |||||||
| @@ -1,9 +1,3 @@ | |||||||
| export type IServerCallActions = |  | ||||||
|   | 'channelSubscription' |  | ||||||
|   | 'processMessage' |  | ||||||
|   | 'channelUnsubscribe' |  | ||||||
|   | 'terminateConnection'; |  | ||||||
|  |  | ||||||
| export interface IServerUnsubscribeActionPayload { | export interface IServerUnsubscribeActionPayload { | ||||||
|   name: string; |   name: string; | ||||||
| } | } | ||||||
|   | |||||||
| @@ -53,7 +53,7 @@ export class ClientUniverseChannel implements interfaces.IUniverseChannel { | |||||||
|    * subscribes to a channel |    * subscribes to a channel | ||||||
|    * tells the universe about this instances interest into a channel |    * tells the universe about this instances interest into a channel | ||||||
|    */ |    */ | ||||||
|   public async subscribe(observerArg?: plugins.smartrx.rxjs.Observer<any>) { |   public async subscribe(observingFunctionArg?: (messageArg: ClientUniverseMessage) => void) { | ||||||
|     // lets make sure the channel is connected |     // lets make sure the channel is connected | ||||||
|     if (this.status === 'unsubscribed') { |     if (this.status === 'unsubscribed') { | ||||||
|       const response = await this.clientUniverseRef.smartsocketClient.serverCall< |       const response = await this.clientUniverseRef.smartsocketClient.serverCall< | ||||||
| @@ -65,8 +65,10 @@ export class ClientUniverseChannel implements interfaces.IUniverseChannel { | |||||||
|       this.status = response.subscriptionStatus; |       this.status = response.subscriptionStatus; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (observerArg) { |     if (observingFunctionArg) { | ||||||
|       return this.subject.subscribe(observerArg); |       return this.subject.subscribe(messageArg => { | ||||||
|  |         observingFunctionArg(messageArg); | ||||||
|  |       },error => console.log); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,3 +1,5 @@ | |||||||
| import * as plugins from './smartuniverse.plugins'; | import * as plugins from './smartuniverse.plugins'; | ||||||
|  |  | ||||||
| export class ReactionResponse {} | export class ReactionResponse { | ||||||
|  |    | ||||||
|  | } | ||||||
|   | |||||||
| @@ -117,7 +117,7 @@ export class UniverseChannel { | |||||||
|   public async push(messageArg: UniverseMessage) { |   public async push(messageArg: UniverseMessage) { | ||||||
|     this.subject.next(messageArg); |     this.subject.next(messageArg); | ||||||
|     const universeConnectionsWithChannelAccess: UniverseConnection[] = []; |     const universeConnectionsWithChannelAccess: UniverseConnection[] = []; | ||||||
|     this.universeRef.universeCache.connectionMap.forEach(async socketConnection => { |     await this.universeRef.universeCache.connectionMap.forEach(async socketConnection => { | ||||||
|       if (socketConnection.authenticatedChannels.includes(this)) { |       if (socketConnection.authenticatedChannels.includes(this)) { | ||||||
|         universeConnectionsWithChannelAccess.push(socketConnection); |         universeConnectionsWithChannelAccess.push(socketConnection); | ||||||
|       } |       } | ||||||
|   | |||||||
| @@ -26,6 +26,7 @@ export class UniverseConnection { | |||||||
|       universeConnection |       universeConnection | ||||||
|     ); |     ); | ||||||
|     universeRef.universeCache.connectionMap.add(universeConnection); |     universeRef.universeCache.connectionMap.add(universeConnection); | ||||||
|  |     console.log('hi') | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user