We have develop our own self-hosted WCF Service, and several PHP applications consume this service to communicate with devices.
To send data to a device we need, the device information and the data we are going to send, we have as well the other way around, get data.
We have several Struct to manage the data: Device, User, UserInfo, DisplayInfo, Events, Logs…
When we send data we use something like:
bool SetUsers(Device d, User[] u);
This is working ok, but with PHP we send data per device, so if we have 50 devices and 2000 users we send 50 times the 2000 users, you can see that this can be better done.
So we thought we could use something like:
bool SetUsers(Device[] d, User[] u);
This as well works ok, but most of the time not all users have to go to all devices, so the latest method is not ok, and the first method is sending to much redundant data.
My question is: what is the best way to send to 50 devices 2000 users or 2000 userInfo or 2000 displayInfo… with one call?
I have thought of three possible ways:
- In the Device Struct include a variable property of several Structs. Best way to send data, wort way to organize data.
- In each Struct, User, UserInfo… include the Device Struct, then we will sort it accordingly to device in our code. Like it, but don’t think is the best way.
- Send all devices + all data relates + a third Struct that relates the two of them. I would have to generate custom ID in each Struct and create a Struct of many-to-many. (don’t know exactly how).
Which one do you think is the best method?
Maybe a new and improved one?
Thanks!!!
If I understand right, your device object can be associated with multiple Users, UserInfo’s or DisplayInfo’s, which case I would logically group them as DeviceUser, DeviceUserInfo and DeviceDisplayInfo objects and have a IEnumerable collection of the User / UserInfo / DisplayInfo inside it.
Example,