In my game I'm trying get opponent's profile picture, but getIconImageUri() returns null, code below only show in log Uri to my profile picture. I also have same problem with player name. My player name is fully displayed (First and Last name) but opponents name is something like "player_123".
for (Participant p : mParticipants) {
if (p.getIconImageUri() != null) {
Log.d(TAG, "avatar " + p.getIconImageUri().toString());
}
// ImageUtils.downloadAvatar(p.getIconImageUri().toString());
}
This sounds like you are connecting with Players that are not in the same circle of sharing. Is this from an invite game or a Random game? (auto-pick)
If you are inviting players, and they are accepting your invite to play, then there may be an issue. Otherwise, it is normal Google+ behavior to not give out the icon or name of Participants if circle matching isn't complete.
From Android Developer Participant
public abstract Uri getHiResImageUri ()
Returns the URI of the hi-res image to display for this participant. If the identity of the player is unknown, this will be null. It may also be null if the player simply has no image.
To retrieve the Image from the Uri, use ImageManager.
Returns
The URI of the hi-res image to display for this participant.
public abstract Uri getIconImageUri ()
Returns the URI of the icon-sized image to display for this participant. If the identity of the player is unknown, this will be the automatch avatar icon image for the player. It may also be null if the player simply has no image.
To retrieve the Image from the Uri, use ImageManager.
Returns
The URI of the icon image to display for this participant.
public abstract String getParticipantId ()
Returns the ID of this participant. Note that this is only valid for use in the current multiplayer room: a participant will not have the same ID across multiple rooms.
Returns
The ID of this participant.
public abstract Player getPlayer ()
Returns the Player that this participant represents. Note that this may be null if the identity of the player is unknown. This occurs in automatching scenarios where some players are not permitted to see the real identity of others.
Returns The Player corresponding to this participant.
Try saving your name, image and unique id in your database on google login and send your id to participants in onRoomConnected() and retrieve participant's image and name from database with the help of received unique id from participant.
Related
I've made a Godot game and put it on my frontend, there are 2 things that happen database-wise when the user uses the site. Firstly he/she enters some details then they play the game and after either winning or losing the result is sent to the backend.
Currently I have two tables made in Postgres: Player and Play_Session; Player is made off the users details such as nickname etc whilst the Play_Session is made out of the game information such as the time it took for them to beat it, their reward etc. I'm trying to connect the two via Players ID and Play_Sessions userId I've made it so that if the two match everything will work as intended and if they do not that it is not a valid submissions. How would I go about doing this? I cannot use something as simple as a serial as if two players play at the same time things will fall apart and one might get the others data. Meaning I mostlikely need to alter my insert statement.
The code I have is the following:
export const createPlayer = async (email: string, nickname: string, address: string, number: bigint): Promise<QueryResult> => {
return await DbConnectionManager.pool.query(`INSERT INTO ${Table.Player} (${PlayerCols.Email}, ${PlayerCols.Nickname}, ${PlayerCols.Address}, ${PlayerCols.Number}) VALUES ($1,$2, $3, $4)`,
[email, nickname, address, number]);
}
----------
export const getPlayerData = () => {
return DbConnectionManager.pool.query(`SELECT ${PlayerCols.Email}, ${PlayerCols.Nickname}, ${PlayerCols.Address}, ${PlayerCols.Number}, ${SessionCols.Date}, ${SessionCols.Reward}, ${SessionCols.Time} FROM ${Table.Player} P JOIN ${Table.Session} ON P.${PlayerCols.Id} = ${SessionCols.UserId} WHERE ${SessionCols.Score} = 50 AND ${SessionCols.Date} = '2021-07-24'` )
}
The Agora.io doc is specifing for the joinChannel method :
The user ID. A 32-bit unsigned integer with a value ranging from 1 to
(2^32 -1). This parameter must be unique. If uid is not assigned (or set
as 0), the SDK assigns a uid and reports it in the joinChannelSuccess
callback. The app must maintain this user ID.
I have 2 use cases :
For the users registered to my app : i want the app to assign an uid
For the users not registered to my app : I want to let agora.io decide of the uid
The issue is that doing so, I may get into collisions between userIds assigned by the app and usersIds assigned by agora lib.
But if you are assigning uids within a range of values (other than 1 -> 2^32) then i could rely on that.
Is it the case ?
thx.
in this case, i think you can use the string user name to join the channel. You can take a look at this doc: https://docs.agora.io/en/faq/string
I am writing a service for forwarding our sensor data to Cumulocity platform. I designed the structure so that all the data is first sent to our main tenant and then device data for each customer is forwarded to corresponding tenants with Data Broker.
I can group devices manually and forward by group but I don't want to deal with it every time a new device is added.Sensor data contains customer name. Probably I can add customer name to device properties (like device_type) and use that as a filter but I want to avoid that if possible. So I thought, when a sensor data hits my endpoint, I do something like this:
Look if the device exists in the database.If it exists just publish measurement data.
If not look at the Group database(Just a key-value store containing customer names and managed Object Ids of the corresponding groups from Cumulocity) to see if there is entry for the customer.
If not add an entry and create a group with customer name.Then add the device to the group.
If it exists, just add the device to the group.
I tried adding devices to groups with REST and it works. The problem is I cannot create a device group with REST.
I looked at the Cumulocity API example requests and tried to tweak them a little.
I tried sending POST request to {{url}}/inventory/managedObjects as:
{
"name": "TestDeviceGroup",
"c8y_IsDeviceGroup": {}
}
It returns 201 created but I cannot see the group. When I try to get collection of groups I see it there as a managed object with a new Id.
I tried to add a new device to this object as a child asset.
{{url}}/inventory/managedObjects/{{GroupId}}/childAssets
{
"managedObject": "id:{{deviceId}}"
}
It returns 201 created but device GROUP is not updated.
If I recreate this scenario with a group created with UI and its Id everything works fine and device is added to the group.
As I understand what I create is not a legit device group and that is the main problem. So my question is How can I create device group with REST?
To create the group you were already on the right track you are just missing the correct type. Create your group like this:
POST /inventory/managedObjects
{
"name": "TestDeviceGroup",
"type": "c8y_DeviceGroup",
"c8y_IsDeviceGroup": {}
}
To assign your device to a particular group you can EITHER assign an existing device to an existing group like this (replace the placeholders in <> with your IDs):
POST /inventory/managedObjects/<groupId>/childAssets
{
"managedObject": {"id":"<deviceId>"}
}
Or you can directly create a new device into an existing group like this:
POST /inventory/managedObjects/<groupId>/childAssets
Content-Type: application/vnd.com.nsn.cumulocity.managedobject+json
{
"name": "my device",
"c8y_IsDevice": {}
}
I was recently asked this in an interview for a SDE role.
Suppose you have a list of User objects
class User {
String userId;
String email;
String ip_addr;
}
where userId field is unique among all users, while ip_addr and email are not necessarily so.
and you know some users have more than one user account (if any two User objects share a common email OR an ip_addr, you classify them as belonging to the same user).
you are required to write a function, whose signature is given as:
List<List<User>> findDups(User[] userList) {
// code here
}
[EDIT] so for example, if there are 7 users, only 2 of which are unique, the function can return something like the following (not necessarily in this specific order):
{
{user1, ip1, email1},
{user5, ip5, email1},
{user24, ip5, email2}
},
{
{user2, ip2, email2},
{user7, ip2, email7},
{user8, ip2, email0},
{user19, ip19, email7}
}
here, in this first group, the first user (user1) is the same user as the second one (user5) as they share the same email address. We also know that the third user (user24) is also the same user as it shares the same ip address (ip5) as the second user in the list.
[/END EDIT]
what data structure would you use and what would be the time complexity of the proposed solution?
I tried to use disjoint set union (quick union), which would give me linear complexity, however the interviewer constantly tried to steer me away from that and said just the Collection API would be enough (Using Lists and Sets and maps).
What would be your approach and solution and the corresponding time complexity?
This is more of a design pattern / document design question than a technical one...
I want to display a activity feed on my website which will list all the latest happenings users have been doing on my site...here are some of the activities i would like to display:
New media uploaded (Bob has uploaded a new track)
Comments on a profile (Paul has commented on Bob's profile)
Comments on media (Steve has commented on Paul's track 'my track name')
Status updates (Steve can write any status update he wishes)
Each activity will need to have it's own set of data, such as the new media uploaded activity I would like to include details about the media such as image, title, description etc).
This activity will mostly be used as a global feed so it's the same for all users, although I need the option for users to only show feed items from users they are following (like twitter).
I think I have 2 options:
1) Pull in all the data Ad-Hoc with an index so the information is always up to date, even if a user alters his media title name...i'm not sure how well this will scale though??
2) Have an ActivityFeed document which contains a Sub-Document such as NewMediaUploadActivity (shown below).
ActivityFeed
- DateTime
- AccountId
- ActivityType
- Activity (this is a polymorphic object)
NewMediaUploadActivity : Activity
- MediaTitle
- MediaDescription
- GenreName
StatusUpdateActivity : Activity
- StatusText
ProfileCommentActivity : Activity
- CommentText
- ProfileAccountId
- ProfileUsername
Etc...
If anybody has any experience, or any input on the best way to do this in RavenDB I would be grateful, my live website built with SQL Server currently does what I need using a slightly modified option 2.
Paul
I would model this as:
public class ActivityTracking<TActivity>
{
public string[] AffectedUsers {get;set;}
public TActivity Activity {get;set;}
}
You can have different activities (not required to be in an inheritance hierarchy) that are "attached" to different users.
For example, Bob commenting on Jane's photo would show up in both streams.
You then can just query for activities for that user.