Jump to content
  • Advertisement

JensB

Member
  • Content Count

    171
  • Joined

  • Last visited

Community Reputation

237 Neutral

About JensB

  • Rank
    Member

Personal Information

Social

  • Twitter
    jensmarcus
  • Github
    JensMarcus
  • Twitch
    Arangar

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. but undefined still shows up after i change addMessages to addMessage.
  2. And... as usual, after I beat my head against it for an hour - spend 10 minutes creatingthe elaborate post above I find the problem: In my client side code, I had the getMessages() function that is called on document ready (only) with this code: function getMessages(){ $.get('http://localhost:3000/messages', (data) => { data.forEach(addMessages); // removed extra () }) } Note the 's' on addMessages (this was the old name for this function) - Stripping that made the document ready actually query the server for the messages, and then of course also displaying them One question remains, where does the "Undefined" come from, that isn't in the tutorial video (but in the code if I run it with my version of node.js)
  3. Slowly working through the tutorial on Node.js - And found another thing that does my head in -.really want to understand what is happening. It's a very simple chat client/server in Express+node.js. When I run my code, this is the browser output: But, when I run the tutorial code, I get this (which is what I think my code should produce as well: When I compare the code from mine and the tutorial, the difference are my use of spaces, and the script scr tags at the beginning of the html, this due to the tutorial is a bit older than current libraries. My questions are: - Why is my code not outputting the contents of the messages array (it doesn't do it neither on first connect, nor when i send message, just starts with undefined) - Why do I get the "undefined" message, in both sets of code - in the tutorial video he does not get it, so I assume it has to do with a version change somewhere, but I'd like to understand it. My code client side, index.html My code, server side, server.js Tutorial code, client side: Tutorial code, server side:
  4. JensB

    Wait what? Did I just choose a genre?

    Sound cool, I'd play it! One thought: I know it's not what you want - But should the server capacity be a problem (physics) - You could create this very game with a vastly simplified UI and graphical representation.
  5. Thanks, yep. I wanted to get the token right before I did the rest and then I’ve not had time. Password validation, not storing and sending clear text etc are all to be implemented
  6. Thanks, a lot of useful input. For clarity, the above code is just a hack. And the feedback I was looking for is on how it does the method 2 in the previous response I was given (hashing a tooken). i don’t understand how random plays into that method? also, could you point me to an established framework? thanks again
  7. I'm working a Node.js class in Udemy, and the instructor runs this code: var fs = require('fs') var data = { name: 'Bob' } fs.writeFile('data.json', data) For him, this produces a data.json file (with inproper data, that's the next step) - However, for me, I get an exception: As far as I can think, it expects "data" to be a callback - But when I look at the docs, writeFile has a version that takes filename, data with no callback - What am I missing here? Class is a few versions back on Node.js, I'm running most current - 11.2.0 EDIT: Figured it out... Never mind, if I had listened for 2 more minutes I'd gotten the answer - Just wasted 10 mins on this He actually got a warning that using it without a callback is deprecated functionality, and I guess it's finally gone now - And I must have misread the docs. Here is the working code, leaving it here if someone else stumbles into this: var fs = require('fs') var data = { name: 'Bob' } fs.writeFile('data.json', JSON.stringify(data),(err) => { console.log("Write finished! ", err) })
  8. Couldn't you run physics in the client to make it "smooth" game-play wise - but then run a simplified version on the server to determine collision/interaction etc? Not sure if that makes any sense, just woke up
  9. JensB

    WindSlayer Private Server

    looking at this thread it seems an easier project to recreate the entire game rather than create a server emulator
  10. Thanks for the clarifications! Very helpful. As I started thinking about this, and sketching on a UDP based C# server to do this - To match both a game client as well as an account management website - I realized if I go for method 2 - Or really either - There is no need to go this low level for a login / account management server. I can just implement this as a web service of some kind, rather than worrying about the UDP level networking - makes sense? EDIT: Of course, that requires me to run a webserver on the account/login server - which shouldn't be an issue I guess. EDIT2: If I went with method 2 above, just doing a simple webservice with a database bellow it would likely be more than enough? Thoughts on that? EDIT3: Here is quick and dirty implementation of creating the tooken, am I getting the concepts right for that? using System; using System.Net; using System.Collections; using System.Collections.Specialized; using System.Security.Cryptography; using System.Text; namespace AccountServer { class AccountServer { public static AccountServer instance = null; private const String secret = "itssekrit"; static void Main(string[] args) { instance = new AccountServer(); WebServer ws = new WebServer(IncommingWebRequest, "http://localhost:8080/AccountServer/"); ws.Run(); Console.WriteLine("Account web server started. Press a key to quit."); Console.ReadKey(); ws.Stop(); } // process incomming web requests // expected format: http://localhost:8080/AccountServer/server?command=login etc // QQQ: From a load perspective, is it a problem that this is a static? What if 100s of web requests come in at once? public static string IncommingWebRequest(HttpListenerRequest request) { try { String command = request.QueryString["command"]; switch (command) { case "login": return instance.WebLogin(request.QueryString); default: return String.Format("Unknown Request"); } } catch(Exception e) { return String.Format("Exception in incomming request:{0}", e.ToString()); } } // web wrapper for login process, returns the tooken if succesfull // test string: http://localhost:8080/AccountServer/server?command=login&uid=jens&pwd=terii&auth=1234 String WebLogin(NameValueCollection qs) { String user = qs["uid"]; String password = qs["pwd"]; String authorization = qs["auth"]; String tooken = ""; if( user == null || password == null || authorization == null ) return "Bad Parameters"; if( Login(user, password, authorization, out tooken) ) { return tooken; } return "Invalid Login"; } // login // returns true if valid, false if not valid - outputs a tooken string as a parameter bool Login(String user, String password, String authorization, out String tooken) { // for now just fake a successfull login tooken = user + ";" + authorization + ";" + DateTime.Now.ToBinary(); var enc = Encoding.ASCII; HMACSHA1 hmac = new HMACSHA1(enc.GetBytes(secret)); hmac.Initialize(); byte[] buffer = enc.GetBytes(tooken); tooken = tooken + ";" + BitConverter.ToString(hmac.ComputeHash(buffer)).Replace("-", "").ToLower(); // are the replaces needed? return true; } } } Here is a link to the WebServer class I'm using: https://codehosting.net/blog/BlogEngine/post/Simple-C-Web-Server
  11. Thanks sorry if this is a newbie question, but what do you mean by authorization above?
  12. I'm conceptualizing this at the moment, so this is more a high level question than a "show me the code". Numerous game ideas I'm throwing around at the moment requires some kind of server side logic, and as such I decided that I want a separated login / authentication server (and as I type this I realize my question might belong in For Beginners - I spent 15 years of my career doing assembly, C, C++ and C# development, but that's a while back and I never did any type of low level network work). Now, my question is - How do I communicate the fact that a certain client is authenticated to the game server? My original idea was that once the client is authenticated, the login server shares a tooken with the client and saves that tooken somewhere - When the client then communicates with the game server, it uses that tooken to establish the connection. The game server then checks with the authentication server if that's a valid tooken. However, this would make the game server dependent on the login servers, and add some load to them. I guess my questions are: 1) is the above a reasonable way of architecting it? 2) if not, any other concepts I should consider? 3) any "ready made" solutions I could make use of, or any specific documentation etc I should read up on? Sorry if this comes up a bit like I'm too lazy to Google it, but I poked around and I think I know a little bit too little to effectively reasearch on my own. I also asked this question on Discord last night and got a "yes" to 1, but just wanted to see if there are more options and if someone can point me at 3.
  13. JensB

    Unity Discord

    Anyone know of a good beginner-intermediate Unity discord? Seems like they are pointing to IRC on the website, and I rather not install mIRC again after not using it for 5+ years
  14. I am doing the 2d roguelike tutorial to familiarize myself with Unity. In the first part (https://unity3d.com/learn/tutorials/projects/2d-roguelike-tutorial/player-and-enemy-animations?playlist=17150) he is clicking a SpriteSheet in the project window (that has been imported from Asset Store) - He then gets a right pane in the project window, where he can shift click individual sprites to drag them to the Player prefab. However, when I do this, I do not get that pane - I do get a preview of the sheet in the inspector - But I can't select in that one. I can still make it work, but with a bit more hassle, so would love to know how to get that window/pane up - Any ideas? EDIT: NM: I loaded the window layout default - and boom, now it looks right Leaving the thread here if someone else have the problem.
  15. JensB

    Game Engine (or game to mod)

    Thanks, will have a look at Skyrim for sure since that seems a re-occuring thought :)   As for world size, I think that fairly small is fine at this stage.  I'm sure long term big would be great, but as a starting point anything is likely to do.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!