Skip to content

khasang/SNet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SNet

Snet is a simple example of social network

We use here next technologies:

  • Spring Framework
  • Spring Security
  • Hibernate
  • PostgreSQL as databas
  • Bootstrap template
  • REST
  • JavaScript

You can find here :

  • Registration (with JQuery validation)
  • Custom Login form
  • Profile page
  • Chats and messages
  • Friends,Invites, and search friends
  • Workgroups and news

=======

Messaging

Snet provides send and receive messages in real time. At this moment available dialog between two users, but further, planned enable conference between dozens of users.

Messages

For access to messages, on the page with list of available chats ( /chats ), just click on button Read messages, after click user will load message's page. Also user can remove existed chat, by using buttom Remove chat.

To send new message, user can use form at lower corner of page messages. Sended message wiil shown last one.

Chats

Chats contains user's messages, act as logical container. To proceed to chat, user can use buttons in profile of another user, buttons near elemnt of list at page friends and button near each result of searching friends, at a corresponding page.

If user starts new chat with another user, with which current user already have dialog twosome, current user will redirect at existed dialog. Otherwise will be created new chat.

Moreover, in a situation where current user have conference between vary of users, and exist another user, which involved in to this conference. If current user creates new chat with another, he will be redirected in dialog twosome with another one. In case of that dialog not exist, it will be created. This feature provides by algorithm below:

...

    private List<Chat> searchingAlgorithm() {
        List<Chat> result = new ArrayList<>();
		Map<Chat, List<User>> discusses = new HashMap<>();
		
        // hayStack - source list of chats
        for (ChatRegistryUnit registryUnit : hayStack) {
            if (discusses.containsKey(registryUnit.getChat())) {
                discusses.get(registryUnit.getChat()).add(registryUnit.getUser());
            } else {
                discusses.put(registryUnit.getChat(), new ArrayList<>());
                discusses.get(registryUnit.getChat()).add(registryUnit.getUser());
            }

        }

        for (Map.Entry<Chat, List<User>> chatListEntry : discusses.entrySet()) {
            if (chatListEntry.getValue().size()==2) {
                result.add(chatListEntry.getKey());
            }
        }

        return result;
    }
...

As input in this method was given haystack is an List. ChatRegistryUnit - entity which contains users and chats. Given list contains all chats registry, where involve users: current and another. Aim of given algorithm is to form list which contains chats, where discuss only our current and another users.

More closely you can see this algorithm, and it's testing in DialogSearcherTest

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published