Hexa
09/29/2018, 5:40 PMfun processIncomingMessages(incomingMessage: List<IncomingMessage>)
is actually a function that thats a list of SomeOtherType
but not IncomingMessage
. SomeOtherType
is just a json message, so I need to process each json message and wrap them in a IncomingMessage class. So it's actually look more like this this ( I try to use jacksonmapper library) // example incoming messages:
// {"message":"message1", phoneType":"iPhoneX", "test1"},
// {"message":"message1", phoneType":"Samsung1", "test2"}
fun processIncomingMessages(incomingMessage: List<SomeType>): Map<MessageIndex, List<Message>>{
//how do I need to process each incoming json messsage and wrap them in IncomingMessage class?
return incomingMessage.forEach {
val eventObj = jacksonObjectMapper().readValue(String(it.data.array()), IncomingMessage::class.java)
}
karelpeeters
09/29/2018, 6:01 PMMessageIndex
-constructor making network calls, where the actual data comes from at first isn't relevant.Hexa
09/29/2018, 6:24 PM{"message":"message1", phoneType":"iPhoneX", "test1"}
is one example of a message that will get sent. Since there will a lot of these message there will be a list of them that that will get sent hence they are in a incomingMessage: List<SomeType>)
. Now it gets a bit tricky to achieve my original goal because I think I need to loop thru each json message first and wrap them to IncomingMessage classkarelpeeters
09/29/2018, 6:24 PM{"message":"message1", phoneType":"iPhoneX", "test1"}
is not valid JSON though.Hexa
09/29/2018, 6:35 PM{"message":"message1", phoneType":"iPhoneX", "someOtherProperty": "test1"}
<----- ah sorry it should be like this so that it can be wrap easily in IncomingMessage class