|
@@ -13,7 +13,7 @@ let toBePassedOverToApp: Subject<BaseMessage> = new Subject()
|
|
let sender: Subject<BaseMessage> = prepareResponseMessages(5, 1000)
|
|
let sender: Subject<BaseMessage> = prepareResponseMessages(5, 1000)
|
|
let serverSocketUrl: string = 'http://192.168.100.96:3000'
|
|
let serverSocketUrl: string = 'http://192.168.100.96:3000'
|
|
let socket: Socket
|
|
let socket: Socket
|
|
-let client: string = 'client2'
|
|
|
|
|
|
+let client: string = 'client3'
|
|
let mongoService: MongoService = new MongoService(client)
|
|
let mongoService: MongoService = new MongoService(client)
|
|
|
|
|
|
|
|
|
|
@@ -83,7 +83,7 @@ async function establishSocketConnection(serverUrl: string): Promise<any> {
|
|
mongoService.write(msg.payload, msg.payload.header.messageID, () => console.log(`Error function doesn't exist.`))
|
|
mongoService.write(msg.payload, msg.payload.header.messageID, () => console.log(`Error function doesn't exist.`))
|
|
// Check the sequence by ensuring the message value before the current message exists, then pass them over to "App"
|
|
// Check the sequence by ensuring the message value before the current message exists, then pass them over to "App"
|
|
// onHoldMessagesSubject.next(msg)
|
|
// onHoldMessagesSubject.next(msg)
|
|
- // checkMessage(msg).then(() => [
|
|
|
|
|
|
+ // checkMessage(msg, onHoldMessageSubject).then(() => [
|
|
// toBePassedOverToApp.next(msg.payload as BaseMessage)
|
|
// toBePassedOverToApp.next(msg.payload as BaseMessage)
|
|
// ]).catch((err) => console.error(err))
|
|
// ]).catch((err) => console.error(err))
|
|
toBePassedOverToApp.next(msg.payload as BaseMessage)
|
|
toBePassedOverToApp.next(msg.payload as BaseMessage)
|
|
@@ -175,22 +175,3 @@ async function sendMessage(message: BaseMessage): Promise<any> {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-// SO concept will be that if the message behind it is received, then
|
|
|
|
-async function checkMessage(message: WrappedMessage): Promise<any> {
|
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
|
- if (message.previousMessageID) {
|
|
|
|
- onHoldMessagesSubject.pipe(
|
|
|
|
- takeWhile(item => message.previousMessageID === item.thisMessageID)
|
|
|
|
- ).subscribe({
|
|
|
|
- complete: () => {
|
|
|
|
- resolve('previousMessageID matched')
|
|
|
|
- // console.log(`${message.payload.header.messageID} : Previous messageID(${message.previousMessageID}) matched`)
|
|
|
|
- // console.log(`matched`)
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- } else {
|
|
|
|
- console.log('No previous messageID. This should be the first message')
|
|
|
|
- resolve('No previous message ID. Please Proceed.')
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
-}
|
|
|