I want to use Phoenix sockets and presence to track users who are currently connected to the Internet (from within an Android application). Is there any online tutorial explaining how to do this? Code sample? Thank you.
In my case I join every user to their own company id, so that I send updates relevant to that company id to their users. For the realtime messaging, you can simply make two users join a room, and send the updates to that room.
Then all you have to do is emit messages to the room, or to the socket id directly. Then on the app connect side you have to process the socket message, you can then either fully refresh the relevant server api, or you can directly modify the data (in this case you have to create the parameters in the socket message).
I have a fibre connection with a modem and one RJ45 going into the wall socket. in the common area, I have the incoming RJ45 from the fibre and additional 4 rooms cables meeting at the same spot. I have put an access point there, the incoming from fibre goes into port 4, and the rooms go into the rest (1 have one room cabled but not in use so pulled out). One of the room gets internet but 2 other rooms do not have internet connection at all. The electrician has tested both ends with the cable tester and it shows connected, but I can't seem to get internet in those 2 points. The access point does not have a light when I connect the other end to a laptop. I have tried swapping the cables around to the access point but no luck. I opened up the wall socket to check the wires, the picture is below. Any advise would be much appreciated.
Attie thx, updated - see layout picture. all rooms terminate at store room. incoming from fibre point also going to store room. i have an access point in the store room. Room 1 & 2 have internet connection, only room 3 with 2 wall sockets does not have any internet but cable tester shows connected. i have taken more pictures of the wiring with the colors and numbers, for one of the sockets in room 3.(apparently i cant add more than 1 image)
I wanted to write a comment, but it got quite long-winded... The formatting of an answer will help, and these things should get you started to find out what's going on. I'm happy to revise as more information comes to light.
If you're lucky, and all the wires are "functional", then you can easily figure out where the runs go with just a computer and a switch. By "functional", I'm meaning that an Ethernet connection can be established - blinky "link" LED on the switch, computer reporting a connection.
You'll want to make sure that the connection is at the expected speed... If you're using a gigabit switch, and a computer that is capable of a gigabit, then Windows (or ethtool should report a 1000Mbps link. If it does not, then this can indicate problems.
It looks like you've identified where the runs go, but it would be good to prove out those connections that currently "don't get internet" - don't look for internet connectivity at first, look for Ethernet connectivity. Then for communication with your router or another PC - use ping -t and check for packet loss.
From your diagram, there should be 5x sockets in the store room. You'll want to put your router in the main hall (close to the "fibre" point), and then use a switch in the store room to connect to the rest of the house.
More (much more) expensive tools will be able to provide you with information on the quality of the run - crosstalk, bandwidth, shorts, length, etc... I'm not advising you to go for a tool like this... Call a pro if you need to.
I'm not familiar with the terminals you've shown... I can only presume that the RJ45 socket is in a separate piece of the faceplate... and I also have to presume that by removing it you've pulled the wires from the punchdown block.
Am I right in saying that in the room there are 4 sockets at the dressing table area (2 x US and 2 x European) and also a old style USB socket by one side of the bed? Any i'm missing? Just thinking how many adaptors I will need as we have UK plugs.
On Seashore there were two EU plugs, and two US outlets separated by two USB ports, at the desk. One USB beside the bed. Since Seascape is one year newer I would think she has at least that. Standard OV cabin. EM
1) I don't want to allow client side direct joning of channel. Clients must not be able to launch socket.join("room"). How can i block those requests? Server is the only one that cares about assigning rooms.
The client-side socket.io library does not have the ability to .join() a room. That ability is only in the server-side library (because that's where the rooms are maintained) and thus the only place it can actually be processed.
So, the only way to join a room is to make your own message for a join request from client to server and process that message on the server on behalf of a given client which enables you to do any sort of checking you want before any client can join a particular room. As such, you should be safe the way you're already doing it.
Similarly, there are only two ways that a client leaves a room. The first is when you process your own message and call .leave() server-side so you can certainly monitor any time that happens since it's your own server-side code calling .leave(). The other way a client leaves a room is when the client disconnects and you can also monitor for disconnects in the server. Like with .join(), the client cannot call .leave() directly so you don't have to worry about that.
I decided to beef this up and make it a useful tool that, potentially, companies could use that as well internally as a chat/conferencing tool. As always there will be several pieces to the article series where I will try to explain some cool code features as well as a cool technology called 'WebRTC'.
I start by explaining the backend - server.js first. Essentially it is responsible for setting up the socket that the client will connect to and it's also responsible for all the room creation/message sending logic. To have a more readable and less clunky code I have created a separate module to hold all information about the rooms - that will be reused at a later stage. The first thing that we need to do in our server.js is to create the socket and import some other libraries (including room.js) as well as setup two objects that will contain information about the people and the rooms and an array that will hold the client objects.:
The next thing to look at is what happens when a person connects to the server, and there are a few things that the code will need to handle. Firstly, it needs to make sure that the people object is correctly populated. I'm using the unique ID generated by socket.io to key off the people object. As per the code snippet below - I'm also adding the name and room keys to the people object. The room key is especially important - as mentioned earlier, each person connected to the server will be able to create one room only. Upon creating a room, the right object's room key will be updated with the ID of the room (I'm going to explain this later with a code snippet), and once room key's value is not null, room creation will be forbidden. As part of the join() function the code also emits two messages to all the clients - a sort of welcome message and another one to list all the connected users - and one message to the connected client showing all the available rooms.
As per the list of requirements, the next thing to implement is the room creation. Every person connected to the server is allowed to create one room. The function responsible for this needs to make sure that every room created has a unique identifier - to achieve this I'm using node-uuid, which is installable via npm: npm install node-uuid. The newly created rooms are essentially going to be new objects that have various properties. Let me talk about about the room.js file for a moment, which is very simple. Upon creating a new room (which is also equal to a new object enabled via the constructor) three parameters are required: name, id and owner. (Probably the owner parameter is not required as the ownership will also be represented in the rooms object located in server.js.
It's time to utilise this code finally. When creating a room, I am also assigning the room's creator to the room immediately - this is achieved by using socket.io's join() method. The function accepts the room's name as a parameter - it is sent from the client. If a person creating a room doesn't have a room created (checked by looking at the room key in the people object) we process the request and attempt creating a room. The details of the room are then stored in the room object on the server, locally, which is keyed off by the unique ID generated by node-uuid.
Now that there is a room created it's time to allow other (connected) people to join it. I like to double check everything on the server side (I just don't trust data received from the client) and even though I can easily hide/disable the 'join' button for the creator of the room and from people who have already joined, using Firebug or Chrome Dev Tools someone may be able to show/enable it again and use it for malicious purposes that may break the application. In light of this, I check whether the person attempting to join is the owner or whether the room contains their ID. If both of these checks fail, only then, I add the person to the room:
There are people online (connected to the server), a room has been created so now it's time to write the function that actually allows the message sending - bearing in mind that only people who are connected to a room can send messages and to only people who belong to the same room. Fortunately, socket.io has this feature built in. By default, every person who connects to server is placed into an empty room - this is the normal socket.io functionality. The client.room = [room.name]( ) will append the list of rooms and will assign the person to the room as well. For testing purposes feel free to try something similar out inside your script:
c80f0f1006