In Java, is there a way to make a client/server system for a game without having to enter ips (like in Minecraft).
But instead, have it automatically connect the user to a game when he requests to join one (like in Fortnite, or surviv.io).
The only method I current know for client/server is having to give each user a server ip to connect to (like in Minecraft), so I was wondering if I could do it this way.
Thanks in advance.
IMHO, I think in all ".io" games, they are only hiding the registration processing. In my case, the previous game I made had a feature calls "Quick Play".
When a player uses that playing method and first time joins the game, I get his device's ID (for example in Android) then use it as a unique ID for that player in-game (I'm not sure about iOS but you can get that unique value in Android).
You can see the example below:
_on(TEvent.CONNECTION_SUCCESS, args -> {
var connection = Connection.convert(args[0]);
var message = TObject.convert(args[1]);
info("CONNECTION", connection.getAddress());
// Allow the connection login into server (become a player)
String username = message.getString("u");
// Should confirm that credentials by data from database or other services, here
// is only for testing
_playerApi.login(new PlayerLogin(username), connection);
return null;
});
Now when a new user login, he will send his device's ID and I can treat him a new player and make that ID as his name (or making a randomized name for him)
You can see more detail in the link below:
Login Example
Related
Their is a requirement in a project to send emails from java application through lotus notes.
Note: the domino server is installed on client server.
Currently i am able to send email using notesFactory on my local machine.using notes.jar file
Which accesses the user by .nsf by its password.
I.e creating secure connection by password.
And gtting database object by calling
Session.getdatabase(null,"user.nsf")
Its perfectly working.
But for some types of emails the client have shared a generic id...(link) over an email... By clicking on that link the generic mail box opens under active user. In separate tab... Through which we can send emails.
But have not shared their .nsf path or id or password.
It directly opens by clicking on that link.
Now i want to access that generic id in notesfactory session
I tried to keep open that id and then running my code...but still it sends email through active user itself.
And client is not ready to share the id and password details of that user. Not the id file is getting generated in our local machine.
Is their any way to send emails through that id?
If anyone want code i am using..ill share.
But for some types of emails the client have shared a generic
id...(link) over an email... By clicking on that link the generic mail
box opens under active user. In separate tab... Through which we can
send emails.
That does not sound like a "shared id", it sounds more like a mail database with the ACL set to give a group of users access.
When you send an email from within Notes (no matter if it is through the UI or through code), the actual logged in user is used as the sender. It is intentionally by design, to prevent users from spoofing the sender.
There is an unsupported way to fake the sender address, by dropping the email directly into mail.box, but that should only be done by someone know what they are doing.
I wrote a script library several years ago, intended to help sending emails. It includes the ability to set the sender address. You can find it on my blog, it's free to use. But I would not recommend you using it without first understanding what the code is doing.
Here is the relevant part of the code:
Set mailbox = New NotesDatabase(mailservername,"mail.box")
If mailbox.Isopen = False Then
Print "mail.box on " & mailservername & " could not be opened"
Exit Sub
End If
Set me.maildoc = New NotesDocument(mailbox)
Call me.maildoc.ReplaceItemValue("Form","Memo")
Set me.body = New NotesRichTextItem(maildoc,"Body")
Call maildoc.ReplaceItemValue("Principal", me.p_principal)
' If principal is set, we want to fix so mail looks like
' it is coming from that address, need to set these fields
Call maildoc.ReplaceItemValue("From", me.p_principal)
Call maildoc.ReplaceItemValue("Sender", me.p_principal)
Call maildoc.ReplaceItemValue("ReplyTo", me.p_principal)
Call maildoc.ReplaceItemValue("SMTPOriginator", me.p_principal)
Call maildoc.ReplaceItemValue("PostedDate",Now())
If me.p_principal<>"" Then
Call maildoc.Save(True,False) ' Save in mail.box
Else
Call maildoc.Send(True) ' Send mail normally
End If
You use the Principal field to set the sender address.
Oo currently I am trying to check and see if its possible to do a single user profile account using firebase authentication under my android project , but here is the kicker which is it should allow me to let my user login using either email, facebook, google, GitHub , etc. from their choosing but after authentication of it, the user is still under 1 account profile, and not separate or a different profile as an example.
sample email from the user :
1. user_gorilla#gmail.com
2. user_apple#yahoo.com
3. hotstuff#hotmail.com
4. this_is_not_a_joke#gmail.com
all of that login and email is just from 1 user and I would want them to have just 1 profile, but enable them to login using multiple emails.
is there currently an in-app function in firebase that does this? or do I have to do and make it myself? because I am currently thinking of doing something along the lines of.
User_profile <- collection name
UID:UID <- this should be the unique document ID
Fullname:
Emails: <-- separate set of collections where the emails for the specific user is stored.
so this is how it goes when the user is created and signed up, the admin still needs to verify "if" the user already has been made inside the collection of user_profile, and if not then the admin would need to create the user_profile and then give the user their unique ID/key.
each time the user creates a new login credentials/authentication login , they need to register it into the admin so that the UI for the profile will show up for the newly created authentication for the user but would still reflect the old profile of the user , its just that the profile gets updated every time and needs to be added by the admin to do so.
would this work out? or does firebase already have something like this kind of function?
so currently i am trying to check and see if its possible to do a single user profile account using firebase authentication under my android project
According to the official documentation regarding Link Multiple Auth Providers to an Account on Android:
You can allow users to sign in to your app using multiple authentication providers by linking auth provider credentials to an existing user account. Users are identifiable by the same Firebase user ID regardless of the authentication provider they used to sign in.
So the key to using this feature is to have the same Firebase user ID.
here is the kicker which is it should allow me to let my user login using either email , facebook , google , github , etc.
Currently, the sign-in methods that are allowed are:
Email/Password
Phone
Google
Play Games
Game Center (Beta)
Facebook
Twitter
GitHub
Yahoo
Microsoft
Or even an Anonymous authentication.
from their choosing but after authentication of it, the user is still under 1 account profile , and not separate or a different profile
For example, a user who signed in with a password can link a Google account and sign in with either method in the future.
What you can't do, is to have users like:
user_gorilla#gmail.com
user_apple#yahoo.com
hotstuff#hotmail.com
this_is_not_a_joke#gmail.com
With different Firebase user ID and link them together. Even if they are the same users, without having the same Firebase user ID, there isn't much to do.
is there currently an in app function in firebase that does this?
No, there is not. If you want to have all those users under a single account, you should create your own mechanism.
or do i have to do and make it myself?
Yes, you need to write code for that. You should match those accounts and somehow convert them into a single one.
or does firebase already have something like this kind of function?
No, it doesn't. The only viable option that you have is to link their multiple accounts using auth provider credentials to a single user account.
Doing a twitchbot as a little hobby project and stumble om a little problem.
I want to make a viewer list where it automatically shows when viewers enter my channel. The problem i got is that the list that is being retrieved only shows the bot. I have read through the javadocs and i thought that i did everything correctly but i just cant get it to work.
So when the bot connects to a server the onuserlist() method is called and retrieves a userlist, but the only user it gets is the bot. Even if i got 5, 10, 100 people in my channel.
#Override
protected void onUserList(String channel, User[] users) {
for (User user1 : users) {
System.out.println(user1);
model.addElement(user1.getNick());
}
super.onUserList(channel, users);
}
The onjoin() method should update the userlist with the following piece of code and it is called everytime someone joins. But even here it is the same problem, the only user that it can find is the bot. I wonder know if someone has got a better knowledge about pircbots and knows what i might be doing wrong?
User[] user=bot.getUsers("#mychannel");
for(int i =0; i<user.length;i++){
System.out.println(user[i]);
}
According to the java doc it should give me a User array of all the people in my channel, but it only gives me one.
http://www.jibble.org/javadocs/pircbot/
User[] user=bot.getUsers("#mychannel");
for (User usr : user){
System.out.println(usr.toString());
}
}
So I just figured this problem out today, if you are using the JOIn/Part system, you need to request permission from the server when you connect using
bot_Object.sendRawLine("CAP REQ :twitch.tv/membership");
This lets Twitch know that you want to use the Join/Part capabilities.
If you want to know more, here is their help guide for setting up different IRC clients, I just pulled the command for permission and used it in my bot.
http://help.twitch.tv/customer/portal/articles/1302780-twitch-irc
What I want to do:
I am trying to make a simple program that posts 5-10 statuses, at a time, on a page's wall. The post to the page will have to be done under the name of the page.
I've read tons of badly written Facebook Developers documentation and I'm reaching the point of confusion where I don't even know what questions to ask. So her I am.
My code so far:
I manually got the Page Access token manually, by this method:
Go to https://developers.facebook.com/tools/explorer
At the GET request form, down there, fill in me/accounts
You'll get a Javascript representation of your basic user data. Find the page you want.
Note the access_token and id fields, we're going to use them in the code below.
Thus, after getting the page Access token manually (And the ID of the page, of course)
import com.restfb.DefaultFacebookClient;
import com.restfb.FacebookClient;
import com.restfb.Parameter;
import com.restfb.exception.FacebookException;
import com.restfb.types.FacebookType;
import com.restfb.types.Page;
import com.restfb.types.User;
/**
*
* #author dsfounis
*/
public class FacebookConnector {
/* Variables */
private final String pageAccessToken = "GOT_THIS_FROM_THE_METHOD_ABOVE";
private final String pageID = "THIS_TOO";
private FacebookClient fbClient;
private User myuser = null; //Store references to myr user and page
private Page mypage = null; //for later use. In this question's context, these
//references are useless.
private int counter = 0;
public FacebookConnector() {
try {
fbClient = new DefaultFacebookClient(pageAccessToken);
myuser = fbClient.fetchObject("me", User.class);
mypage = fbClient.fetchObject(pageID, Page.class);
counter = 0;
} catch (FacebookException ex) { //So that you can see what went wrong
ex.printStackTrace(System.err); //in case you did anything incorrectly
}
}
public void makeTestPost() {
fbClient.publish(pageID + "/feed", FacebookType.class, Parameter.with("message", Integer.toString(counter) + ": Hello, facebook World!"));
counter++;
}
}
The problem:
The code above works. The thing is, it works temporarily. The page access token that I get has an expiration time of one hour, and I need to manually go through the process of obtaining it, every time that I run the program. What is the point of automating a process if I keep some aspects of it manual?
So I have to ask you: Can I do the process above programmatically, and obtain a fresh page access token at program launch?
Can I, maybe, use a better API to do something as simple as just post a couple of things on a Page's wall, every day?
My application is a console one, and I would like to stay away from implementing needless Logins, even though if you tell me that it is needed, it's going to be a bother I'll have to go through.
As a note: I've got the application registered in Facebook Developers, albeit only as a basic app. To get more permissions, I need to show proof of Facebook Login implementation, and as I say in the title, it's something I'll have to avoid.
There is no automatic process to obtain an access token. If there was, it will defeat the whole purpose of the OAuth flow. For pet projects and tests it's okay to use the Graph API Explorer but for public applications involving users it is mandatory that the user manually selects the login dialog.
Under your current scenario you can extend the user token using the method mentioned here https://developers.facebook.com/docs/roadmap/completed-changes/offline-access-removal/
Scenario 5: Page Access Tokens
When a user grants an app the manage_pages permission, the app is able
to obtain page access tokens for pages that the user administers by
querying the [User ID]/accounts Graph API endpoint. With the migration
enabled, when using a short-lived user access token to query this
endpoint, the page access tokens obtained are short-lived as well.
Exchange the short-lived user access token for a long-lived access
token using the endpoint and steps explained earlier.
https://graph.facebook.com/oauth/access_token?
client_id=APP_ID&
client_secret=APP_SECRET&
grant_type=fb_exchange_token&
fb_exchange_token=EXISTING_ACCESS_TOKEN
By using a
long-lived user access token, querying the [User ID]/accounts endpoint
will now provide page access tokens that do not expire for pages that
a user manages. This will also apply when querying with a non-expiring
user access token obtained through the deprecated offline_access
permission.
A simple program used only by the owner of the application does not need approval from Facebook.
e.g. https://www.facebook.com/phwdbot
I am following the Client side GCM code on the Android dev site; I came across this:
private void sendRegistrationIdToBackend() {
// Your implementation here.
}
Now this questions is not WHAT to implement there, I know how to do httpost's and send param's to the server.
My questions is WHERE do I send this in my Database?
I am implementing GCM in an app that already has registered users, so I have a users MySQL table. Now here are my questions: From what I have read, do RegistrationId's have a unique relationship with a user? If so, can I just put the RegistrationId for the user into a new column in my users table? The only issue I see: What if the user uses the app on multiple devices. So that makes me think my logic is wrong. And if it is wrong...
..should I just do what I have seen in demos and put registration ID's in their own table -- and if so, should they be put there with the user Id in the same row so that a reg Id can be identified to a particular user (not just device)?
The relation between a user and a Registration ID is many-to-many :
As you realized, if a user has multiple devices, that user would be associated with multiple Registration IDs.
If on a single device one user logs out and another user logs in, both would be associated with the same Registration ID. In that case, however, you can cancel the association of the Registration ID to the old user before associating it with the new user. This would simplify the relation between a user and a Registration ID to one-to-many.
Given those two points, having a table that contains for each Registration ID a user ID would work. Just don't forget to remove entries from this table when users log out, since when a user logs out in a specific device, the Registration ID that what given to that instance of the app is no longer associated with that user.
It depends on what your app wants to do:
If the user will use only one device you can put it in the user table.
If the user can have many devices and the same notifications should be sent to all of them you can have a list of registration ids for each user (a one to many table).
If each device will have different notifications you should add a table for the devices, and add the registration id there.
You could also group the registration IDs related to a single user using the notification key.
http://developer.android.com/google/gcm/notifications.html
That way you have one entry per user and you only need to send one message per user, GCM takes care of the rest.