You are on page 1of 59

A Project Report On

“Gamer’s Profile”

Submitted to the
School of Computer Science of

Yashwantrao Chavan Maharashtra Open University


In Partial fulfillment of
The Requirements for the Degree of
Bachelor Of Computer Application (B.C.A)
Academic year 2017-18
Semester VI

Submitted By
Burhanuddin Banswada Wala
And
Kalawadwala Burhanuddin Inayat

Under The Guidance of


Ritesh Jadhav

Declaration
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

We Burhanuddin Banswada Wala and Kalawadwala Burhanuddin


Inayat students of T.Y. B.C.A Semester VI (2017-2018) hereby declare that
we have completed this Project Work titled “Gamer’s Profile”. The project
Report has been (Accepted/Rejected) for the partial fulfillment of B.C.A
programme.

Date:

Place: Signature of Students


T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

Certification of Completion

I Ritesh Jadhav, hereby Certify that Burhanuddin Banswada Wala and


Kalawadwala Burhanuddin Inayat of St. Angelo’s Computers Ltd. of T.Y.
B.C.A (semester VI) has completed their Project on “Gamer’s Profile” in
the academic year 2017-2018 under my guidance and supervision. The
project report has been written according to the guidelines given by the
Yashwantrao Chavan Maharashtra Open University.

Name of Examiner Signature of the Examiner

Stamp of Study Center Signature of the Coordinator


T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

Acknowledgement

We own a debt of gratitude towards Mr. Ritesh Jadhav by giving his Precious
time and support in solving our queries, clearing doubts about Project, given
his Valuable Knowledge.

We’d like to thank our Coordinator, Mrs. Poonam Sharma, for her patience
and for sharing her expertise whilst giving us the space to work in our own
way.

We cannot thank our families enough for bringing us up the way they did.
They are the source behind our excellence.

This list would be incomplete without mentioning all of the developers and
education institutes around the world that share their knowledge, work, and
wisdom over the Internet.
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

Preface

It gives us immense pleasure in presenting this book, Apache Tomcat


Server, .Net-based API For Client and JSP Website we developed together as
our final year B.C.A Project.

The Idea came to us first by playing Digital Games, where we used to get
Achievements and Level completion Scores in some particular Digital Games
which get stored in local Storage of Device platform where that Game in
installed. But at the time we didn’t seem to think much of it. Getting those
Achievements and Scores upon playing Digital Games seemed too much
ordinary and we couldn’t think of any reason why any players need
Achievement in those Digital Games so we didn’t stick long and soon we
were looking for other ideas for the Final year project over the course of
Semester 5. Then an accident took place on our Gaming device got wiped
out and all the Digital Game’s save game data, achievement and Scores got
reset and there was no way recovery, now we cannot even show our
progress to our friends / families. we can imagine, there are millions of
people who play the Digital Games and never get opportunity save their
game data on a permanent basis. this hit us with a desperate need for some
systems that can upload and store Digital Game User Data on a dedicated
server database.

Since we are Not Game Developers, we can’t Develop our own Digital Game,
but We do need at least one Example Digital Game’s source code, so for we
can build and test API which shall Serve us as a client-side connecting our
server. So We choose “Bomberman”, A Digital Game which is available as
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

open source On Github.

Synopsis

BURHANUDDIN BANSWADA WALA - 2015017000904824


KALAWADWALA BURHANUDDIN INAYAT - 2015017000904816
T.Y. B.C.A
Project Synopsis of the title “Gamers Profile”

Introduction:
In Today's World, Digital Games Demand is skyrocketing, this leads to
increase in the numbers of Digital Games being published on Gaming Market
for the variety of Gaming Consoles (such as Windows PC, Android,
Playstation, Xbox etc), so all the players need one Central Hub where they
can Store and analyze their all Digital Game’s Progression Data in one place
such as game Score, Achievements, Microtransactions, etc. So We are happy
to Introduce our project “Gamer’s Profile” which provides these features and
allows players to share their Digital Games progress with their Friends and
Colleagues, also stores Digital Game’s Progression Data in case if the player
wants to continue their games progression state across different devices.

Objective:
● -Building an API for the Game Developers.
● -Setup Microtransaction purchases on Game Modules for the Game
Developers.
● -Receive User Game Progression Data from the API Implemented in
Games.
● -Storing Game Data such as Achievements, Score, etc on our Server
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

Database.
● -Display Achievements on “Gamer’s Profile” website.
● -Restoring Game Progression Data.
● -Sharing Profile State on the website.
● -Chatting System

Hardware Requirements:
-Any CPU with more than 1Ghz
-RAM 2GB
-Storage more than 1Gb free space on the Hard Disk

Software Requirement:
-Linux Ubuntu v14.04
-Web browser
-Front-end:-
-Client side :- HTML5 , CSS , Javascript.
-Server side :- Jsp / Servlet , Apache Tomcat.
-Back-end:-
-DataBase - Oracle 11g XE
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

Table of contents
Declaration
Certification of Completion
Acknowledgement
Preface
Synopsis
Development Phase
The Need
- Problem Definition

- Existing System

The Proposal
- Solution Strategy

Feasibility study
- Technical Feasibility

- Economic Feasibility

- Legal Feasibility

- Operational Feasibility

- Schadule Feasibility
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

The Need

Problem Definition:

First of all!, People thinks Digital Games are Waste Of Time, for that reason
some people play Digital game very less often and they are Partially true, it's
just Same way listening to music is a waste of time. But in advantage view,
music helps us Lowering Stress and Improves Health, So Playing Digital
game help to indulge one's brain in constant stimulation, thus improving the
brain's performance. now it totally depends on Who is playing the Digital
Games and for how long. But still, on this earth, according to 2016 record,
out of 7 billion people, 2.5 billion plays Digital games at least couple of hours
in a week, these numbers are quite A lot and it's very Positive in Business
Point of view.

With the increase in Computing power, Digital games become more Powerful
and artistic, this brings drastic increase in the number of Digital Games
across most of the Gaming platform such as PC, PlayStation, XBox,
Nintendo, etc, with increasing demand, this makes a bit difficult for Gamers
to keep track of their each Games progression especially when there are
multiple platforms.

Also the fact sometimes accidents may cause Game data to get wiped and
the Gamer left no choice but to start over again.
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

Existing system:

Digital Game Achievement Data usually Stored in local Storage, Which is


neither a big deal for an average Gamer nor they care. But until some
incidents happened like data loss, the same thing seemed to happen with us
then realized why it's so important to not to rely on Local Storage.

Also there are more factor of losing Digital Game Progression data for
example when a Player Completed just half of the Game progression then
uninstalled it for try other new latest Digital Games to fit into his storage,
now even if game saved data has been kept untouched, most of modern
Operating systems don’t like to keep the residual leftover file of uninstalled
applications and they get deleted as well, then after about a year that Player
when decide to get back to that old Digital Game he needs to start over
again. Also, another possible factor is when if someone else gets into the
game and start new game result in losing last Save Digital Game progression
data.

Some big company like Google, Microsoft saves Player Achievement data on
cloud account, but they are specific to their own Products like Google for just
Android OS platform and Microsoft for their Xbox Platform. It’s an obvious
Google never can interact with Microsoft’s Xbox Digital game and vice versa.
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

The Proposal
Solution Strategy:

The solution to address those problems and needs is to create a dedicated


Server and Database, to store Player’s Digital Game Progression data such
as Achievements, scores per each level, etc.

Now Question arises, how we add Digital games to our Server and how those
Games possibly send such game progression data to our Server? Simply
answer is NO! we don't add any Digital Games ourself or hack into any of
them.

So how this Works? We provide separate Developer section in our Website,


any user can become Developer if they are in Digital Game Development
business and can Buy Game Module Slot where they can add their Games,
add all Achievement and level score data and download our API and setup In
their Game Source Code.

API Gamer’s Profile Server


Digital Game
-Level Scores
-Achievements
DB Web

Whereas For Game players just need to register on our Gamer’s Profile
Website and just login in the Digital Game as well, and continue Enjoying
gameplay, our API automatically detect any Achievements and completed
level Scores and send it to our Server, so next time when player login to our
Website, they can see the displayed their updated progression.

Also when the player Uninstalled their games or any data loss, they can
simply login to the game with Gamer’s profile Account and All Progression
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

data shall be restored.

The basic steps need to follow by the Player:


● Open www.Gamersweb.com website.
● Register an account.
● Install and Open Bomberman.apk (Example game).
● Login in with Gamer’s Web Account on Bomberman.
● Play a couple of levels and get some Achievements.

The basic steps need to follow to restore game data:


● Install and Open Bomberman.apk (example game).
● Login in with Gamer’s Web Account on Bomberman.
● Game Progression data restored Automatically.

The basic steps need to follow by the Developers:


● Open www.gamersweb.com or www.developer.gamersweb.com
Website.
● Register an Account.
● Buy a Game Module.
● Make payment through Paypal.
● Download API from the website.
● Integrate API into Game Source code.
● Set Achievements on the website.
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

Feasibility Study
TELOS refers to the five areas of feasibility - Technical, Economic, Legal,
Operational, and Scheduling. All of these factors were analyzed and studied.
A highly brief summary of the report and results are given below.

Technical Feasibility:

To develop such Server, Website, and API, the following technical skills and
tools are required.

● JDK v8
● MonoDevelop IDE (API Development)
● Visual Studio IDE (API Compilation)
● Eclipse IDE (Backend Development)
● Apache Tomcat Server v7.0
● SQL Developer IDE
● Oracle v11g
● Unity Game Engine (API Integration test)
● DreamWeaver (Website Designing)
● Web tool: Login by Google API, Gsmtp.jar, Bootstrap.css, jquery, Ajax,
etc
● Sandbox PayPal for Developers

We have work on this Project that use JSP and .NET technologies. We have
learned Java and C# Programming Language Extensively. The transition is
expected to be Smooth.

All of the above technical requirements are fulfilled. The project is technically
feasible.
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

Economic Feasibility:

Considering that this is an undergraduate project, ROI and profit in terms of


money is not expected. However, We must and did take into consideration
whether developing the product itself was within budget.

The cost of a suitable workstation, libraries, test device, and other


components was found to be within budget. The project is indeed
economically feasible. However, Keeping Server Alive up and Running all the
time may keep on adding our cost.

We are distributing the Website and Data Storage service for free of charge
to players, but there will be some Internet/data charges as this project is
based on internet connection, also we made some Charges on Buying Game
module For the Developer Who are in the game development business just
to Address our cost by keep server alive, so the product is economically
feasible for the end user.

Legal Feasibility:

There will be some Basic private user Data being saved on our Database, as
the user need to register on our Website using Required personal Data such
as Email ID, username, DOB, Country location, Gender and Profile Image.
We intend to Store such Data just purely for basic Identification purpose. We
never intended to Share or Sell these Privacy data to any other third party
organizations.

The developer, however, has no control over how the user makes use of Our
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

Service and hence is not responsible for it and is absolved of any liabilities
arising therefore. The product is legally feasible.

Operational Feasibility:

The service is Applicable only to people who play Digital Games. This service
required no installation, just simply register on Website and login in the
Inside the Digital game with almost no setup configuration required.

A study on Remote Digital Games Progression Data Storing for all Gaming
platforms was performed. If we were able to compare this Service with other
similar Services, we would find this most of these services are bonded with
particular Digital Gaming Platform such as Google play games only for
Android games, and Xbox cloud service for Xbox only, etc, in contrast, this
our Service (Gamer’s Profile) designed to work for all platforms due to the
Compiled API we developed is simple and can easily able to integrated on
any Digital Game Source code of any platforms.

This Gamer’s Profile Service is operationally feasible.

Schedule Feasibility:

We have worked on other projects before, in the field of Android applications


and Game Development For PC. Taking past experience as well as expert
advice into consideration, the effort and schedule break up showed that the
project was likely to be delivered on time.
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

Initial Demonstration
A throwaway prototype was developed to demonstrate that the critical use-
cases, primary scenarios and requirements were satisfied. This prototype
also tested the performance, response time, capacity, accuracy, and range
of the application. The main concerns that were addressed are as follows:

● Does the Server up working and running?


● Does the Website visible and correct layout?
● Does the Database working and Operational?
● Does all the Forms elements (register, login, profile edit, etc) all
Operational?
● Upon submitting data from each of the Form elements being received
by the Server?
● Does the API integrate into the Example Digital Game “Bomberman”
properly connecting to the Server?
● Does the Data Being received from integrated API (such as
Achievements) to the Server?
● Does the received Data on the Server being updated on the Database?
● Does the Website Dynamically updating based on newly received Date
on the server?
● Do the Users can able to successfully Signup and Login?
● Do the Users can Able to Edit profile, change and reset password?

The results of this throwaway prototype are summarized in the following


table. The screenshots of the prototype are displayed next.
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

Test cases Test result

Server Running properly Success

Socket Communication working Success

Website layout All functional

Database Functional Success

API Functional Success

Website form elements All functional

Server crash On Rare occasions


T.Y. Bachelor Of Computer Application (B.C.A) YCMOU
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

Gantt Chart
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

ERD
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

Use Case Diagram


T.Y. Bachelor Of Computer Application (B.C.A) YCMOU
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

Sequence Diagram
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

Data Model Diagram


T.Y. Bachelor Of Computer Application (B.C.A) YCMOU
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

C# .NET API Code

ProgressionRecorder.cs
using System;
using System.Collections.Generic;

public class ProgressionRecorder


{
static SocketCommunication socket;
private Char space;
private String ResponseMsg;
private Char[] MsgDecorder;
private String GameData;
private String pid;
private String did;
public List<String> bulkAchievements;
public List<String> bulkLevelsid;
public List<String> bulkLevelpts;
private bool isLoggedIn;

public String getdata{


get{
return GameData;
}
}

public ProgressionRecorder(){
space = ' ';
socket = new SocketCommunication();
}

public String ValidateLoginCredentials(String gid , String did ,


String username , String password){
Console.WriteLine("Client Message of ValidatorLoginCredentials = c" +
gid + space + did + space + username + space + password + space);
ResponseMsg = socket.SocketMessageSender("c" + gid + space + did +
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

space + username + space + password + space);


MsgDecorder = ResponseMsg.ToCharArray();
switch (MsgDecorder[0]){
case 'f':
Console.WriteLine("Server Response F(Wrong
Credentials)" );
return "f";

case 'n':
pid = ResponseMsg.Substring(1);
this.did = did;
isLoggedIn = true;
Console.WriteLine("Server Response N(new User)");
return "n";

case 'p':
this.did = did;
isLoggedIn = true;
RestoreCloudData();
Console.WriteLine("Server Response P(Previous Game
Progression found)");
return "p";
}
return "f";
}

private void RestoreCloudData(){


Console.WriteLine("RestoreCloudData");
int currIndexPos = 1;
pid = "";
do
{
pid += MsgDecorder[currIndexPos];
}while(MsgDecorder[++currIndexPos] != 'a');
RestoreAchievements(currIndexPos);
}
private void RestoreAchievements(int lastIndexPos){
bulkAchievements = new List<string>();
string letters = "";
while (MsgDecorder[++lastIndexPos] != 'l'){
if (MsgDecorder[lastIndexPos] == ' '){
bulkAchievements.Add(letters);
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

letters = "";
continue;
}
letters += MsgDecorder[lastIndexPos];
}
RestoreLevels(lastIndexPos);

for (int i = 0; i < bulkAchievements.Count; i++){


Console.WriteLine("Achievements" + bulkAchievements[i]);
}
}

private void RestoreLevels(int lastIndexPos){


bulkLevelsid = new List<string>();
bulkLevelpts = new List<string>();
string key = "";
string value = "";
while (++lastIndexPos < MsgDecorder.Length){
if (MsgDecorder[lastIndexPos] == ' '){
while (MsgDecorder[++lastIndexPos] != ' '){
value += MsgDecorder[lastIndexPos];
}
bulkLevelsid.Add(key);
bulkLevelpts.Add(value);
value = "";
key = "";
continue;
}
key += MsgDecorder[lastIndexPos];
}

for (int i = 0; i < bulkLevelsid.Count; i++){


Console.WriteLine("Levels\t" + bulkLevelsid[i] + "\t" +
bulkLevelpts[i]);
}
}

public String CloudCurrentData(){


if (pid == null){
return "f";
}
String MessageString = "b";
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

MessageString += pid;
MessageString += " ";
MessageString += did;
MessageString += "a";
for (int i = 0; i < bulkAchievements.Count; i++){
MessageString += bulkAchievements[i];
MessageString += " ";
}
MessageString += "l";
for (int i = 0; i < bulkLevelsid.Count; i++){
MessageString += bulkLevelsid[i];
MessageString += " ";
MessageString += bulkLevelpts[i];
MessageString += " ";
}
Console.WriteLine("Cloud Current data = " + MessageString);
return socket.SocketMessageSender(MessageString);
}

public bool RecordAchievements(String Achid){


if (isLoggedIn){
Console.WriteLine("Achievement sent Message = a" + pid +
space + did + space + Achid);
socket.SocketMessageSender("a" + pid + space + did +
space + Achid);
return true;
}
return false;
}

public bool RecordLevels(String Lid, String LPoints){


if (isLoggedIn){
Console.WriteLine("Level sent Message = l" + pid + space +
did + space + Lid + space + LPoints);
socket.SocketMessageSender("l" + pid + space + did +
space + Lid + space + LPoints);
return true;
}
return false;
}}

SocketCommunication.cs
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

using System.Net;
using System.Net.Sockets;
using System;
public class SocketCommunication
{
int sendLen;
int rcvMsgLen;
byte[] sendBytesLen;
byte[] rcvMsgBytesLen;
byte[] sendBytes;
byte[] rcvMsgBytes;
string sendMsg;
string rcvMsg;
public static string ip;
private static string ipadd;

IPEndPoint serverAddress;
Socket clientSocket;
public static void ChangeIP(){
if(ip != null){
ipadd = ip;
Console.WriteLine("assigned ip address = " + ipadd);
}
else{
ipadd = "192.168.0.104";
Console.WriteLine("default ip assigned = " + ipadd);
}
}

public SocketCommunication(){
if (ip == null){
ipadd = "192.168.0.104";
}
serverAddress = new IPEndPoint(IPAddress.Parse(ipadd), 9191);
clientSocket = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
}

public bool EstablishConnection(){


Console.WriteLine("Connection Established at given IP address =
" + ipadd + " and port number = 9191");
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

clientSocket.Connect(serverAddress);
return clientSocket.Connected;
}

public bool DetachClient(){


clientSocket.Disconnect(true);
Console.WriteLine("Connection Closed");
return clientSocket.Connected;
}

public string SocketMessageSender(string sendMsg){


EstablishConnection();
// Sending
sendLen = System.Text.Encoding.ASCII.GetByteCount(sendMsg);
sendBytes = System.Text.Encoding.ASCII.GetBytes(sendMsg);
sendBytesLen = System.BitConverter.GetBytes(sendLen);
clientSocket.Send(sendBytesLen);
clientSocket.Send(sendBytes);
Console.WriteLine("Send Message String = " + sendMsg);

// Receiving
rcvMsgBytesLen = new byte[4];
clientSocket.Receive(rcvMsgBytesLen);
rcvMsgLen = System.BitConverter.ToInt32(rcvMsgBytesLen, 0);
rcvMsgBytes = new byte[rcvMsgLen];
clientSocket.Receive(rcvMsgBytes);
rcvMsg = System.Text.Encoding.ASCII.GetString(rcvMsgBytes);
DetachClient();
Console.WriteLine("Recieve Message String = " + rcvMsg);
return rcvMsg;
}
}

AchievementDataEntry.java
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

package com.gamersweb.servlets;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@WebServlet("/AchievementDataEntry")
public class AchievementDataEntry extends HttpServlet {
private static final long serialVersionUID = 1L;

int gamekey;
int Achno;
String Achname;
String Achdesc;
String userid;
String code;

crudOperations crudforachievements;

public AchievementDataEntry() {
super();
crudforachievements = new crudOperations();
}

protected void doPost(HttpServletRequest request,


HttpServletResponse response) throws ServletException, IOException {
HttpSession session = request.getSession();
PrintWriter out = response.getWriter();
userid = session.getAttribute("userid").toString();
code = request.getParameter("code");
try {
switch(code) {

case "s": //For SingleEdit


T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

gamekey =
Integer.parseInt(request.getParameter("gamekey"));
Achno =
Integer.parseInt(request.getParameter("achno"));
Achname = request.getParameter("achname");
Achdesc = request.getParameter("achdesc");
crudforachievements.EditAchievement(gamekey, Achno,
Achname, Achdesc);
out.write("200");
break;
case "b":
gamekey =
Integer.parseInt(request.getParameter("gamekey"));
System.out.println(gamekey);
System.out.println(request.getParameter("message"));
crudforachievements.SaveAchievements(gamekey ,
request.getParameter("message"));
out.write("200");
break;
default:
out.write("500");
}
}catch(SQLException e) {e.printStackTrace();}

}
}

EmailPosting.java
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

package com.gamersweb.servlets;
import javax.mail.*;

import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import java.util.*;
import javax.servlet.annotation.WebServlet;

@WebServlet(description = "File is Created to validate the Game


Developer Identification", urlPatterns = { "/DevsIdentification" })
public class emailposting {

public static enum weblink { VerifiedEmailListener ,


SetPassword , SuccessPasswordWindow };

String sender_gmailaddress = "abbasburhanuddin52@gmail.com";


String sender_password = "we319661999";
String google_host = "smtp.gmail.com";
String google_port = "465";
String starttls = "true";
String auth = "true";
String socketfactoryclass = "javax.net.ssl.SSLSocketFactory";
String fallback = "true";
String Body = "";
boolean debug = true;
String reciever_gmailaddress;
String verificationurl;
String URLfilename;

//Object initialization
Properties gmail_confs;
Session session;
MimeMessage msg;
Transport transport;

public emailposting() throws MessagingException {


super();
}

public void emailDispatchingProcedure(String email , String


encoded_email , String subject , String GeneratedId ,weblink wlinks)
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

throws MessagingException {
gmail_confs = new Properties();
URLfilename = wlinks.toString();
gmail_confs.put("mail.smtp.user", sender_gmailaddress);
gmail_confs.put("mail.smtp.host", google_host);
gmail_confs.put("mail.smtp.port", google_port);
gmail_confs.put("mail.smtp.starttls.enable",starttls);
gmail_confs.put("mail.smtp.auth", auth);
gmail_confs.put("mail.smtp.debug", debug);
gmail_confs.put("mail.smtp.socketFactory.port",
google_port);
gmail_confs.put("mail.smtp.socketFactory.class",
socketfactoryclass);
gmail_confs.put("mail.smtp.socketFactory.fallback",
fallback);
session = Session.getDefaultInstance(gmail_confs, null);
session.setDebug(debug);
msg = new MimeMessage(session);
msg.setSubject(subject);
msg.setFrom(new InternetAddress(sender_gmailaddress));
transport = session.getTransport("smtp");
transport.connect(google_host, sender_gmailaddress,
sender_password);
verificationurl =
"http://localhost:8080/GamersProfileAndForum/"+URLfilename+"?
key="+GeneratedId+"&address="+encoded_email;
reciever_gmailaddress = email;
Body = verificationurl;
msg.setText(Body , "UTF-8", "html");
msg.addRecipient(Message.RecipientType.TO, new
InternetAddress(reciever_gmailaddress));
msg.saveChanges();
transport.sendMessage(msg, msg.getAllRecipients());
transport.close();
}
}

ImageUploadListener.java
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

package com.gamersweb.servlets;
import java.io.File;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;

@WebServlet("/ImageUploadListener")
public class ImageUploadListener extends HttpServlet {
private static final long serialVersionUID = 1L;

String filepath = "/home/burhanuddinabbas/Pictures/Userimg/";


String userid;
PrintWriter out;
int MaxMemSize = 5000 * 1024;
int MaxFileSize = 5000 * 1024;

public ImageUploadListener() {
super();
// TODO Auto-generated constructor stub
}

protected void doPost(HttpServletRequest request,


HttpServletResponse response) throws ServletException, IOException {
HttpSession session = request.getSession();
out = response.getWriter();
userid = session.getAttribute("userid").toString();
if(userid != null &&
ServletFileUpload.isMultipartContent(request)) {
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

try {
DiskFileItemFactory factory = new
DiskFileItemFactory();
factory.setSizeThreshold(MaxMemSize);

ServletFileUpload upload = new


ServletFileUpload(factory);
upload.setSizeMax(MaxFileSize);

List<FileItem> imag =
upload.parseRequest(request);
for(FileItem item : imag) {
if(!item.isFormField()) {
File file = new File(filepath +
session.getAttribute("userid").toString());
item.write(file);

System.out.println(item.isInMemory());
System.out.println(item);
out.write("P");
}
}
}
catch(Exception ex) {ex.printStackTrace();}
}
else{
out.write("F");
}
}
}

OracleConnection.java
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

package com.gamersweb.servlets;
import java.sql.*;

public class OracleConnection {


public static Connection StdCon;

public static void StandardOracleConnection()


{
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
StdCon =
DriverManager.getConnection("jdbc:oracle:thin:@localhost:7070:xe","Ga
mersProfileDB","240245");
} catch (Exception e) {
e.printStackTrace();
}
}

SocketServiceProvider.java
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

package com.gamersweb.servlets;
import java.io.IOException;

import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.sql.SQLException;

public class SocketServiceProvider {

static ServerSocket serverSocket;


static Socket socket;

static InputStream is;


static OutputStream os;

static byte[] receivedBytes;


static byte[] sendBytes;

static byte[] sendLenBytes;


static byte[] receivedlenBytes;

static int len;


static int toSendLen;

static String received;


static String toSend;

static MessageInterpreter messageString;

public static void main(String[] args) throws IOException ,


SQLException{
EnableSocketConnection();
}

public static void EnableSocketConnection() throws IOException,


SQLException{

messageString = new MessageInterpreter();


T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

serverSocket = new ServerSocket(9191, 10);


while(true) {
socket = serverSocket.accept();
SocketRequestListener();
}
}

public static void SocketRequestListener() throws IOException,


SQLException{
is = socket.getInputStream();
receivedlenBytes = new byte[4];
is.read(receivedlenBytes, 0, 4);
len = (
((receivedlenBytes[3] & 0xff) << 24)
| ((receivedlenBytes[2] & 0xff) << 16)
| ((receivedlenBytes[1] & 0xff) << 8)
| (receivedlenBytes[0] & 0xff)
);
receivedBytes = new byte[len];
is.read(receivedBytes, 0, len);
received = new String(receivedBytes, 0, len);
System.out.println("Recieved" + received);
messageString.MessageResolver(received);
}

public static void SocketResponder(String send) throws


IOException {
os = socket.getOutputStream();
sendLenBytes = new byte[4];
System.out.println(send);
String toSend = send;
sendBytes = toSend.getBytes();
toSendLen = sendBytes.length;
sendLenBytes[0] = (byte)(toSendLen & 0xff);
sendLenBytes[1] = (byte)((toSendLen >> 8) & 0xff);
sendLenBytes[2] = (byte)((toSendLen >> 16) & 0xff);
sendLenBytes[3] = (byte)((toSendLen >> 24) & 0xff);
os.write(sendLenBytes);
os.write(sendBytes);
socket.close();
} }
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

DeveloperContent.jsp

<!-- Start of Developer Game List -->


<div id="accordion" class="pt-3">

<%@ page import="com.gamersweb.servlets.EnDecoding


,com.gamersweb.servlets.crudOperations , java.sql.ResultSet,
java.util.*" %>

<%
String encodedClientID;
String ClientID;
String totalachievements;

ArrayList<Integer> gamekies = new ArrayList<Integer>();


ArrayList<String> encodedgamekies = new ArrayList<String>();

crudOperations crudforgamespecs = new crudOperations();


EnDecoding encodeids = new EnDecoding();
ResultSet tabledata;
%>

<%
crudforgamespecs.StandardDBConnection();
ClientID = session.getAttribute("userid").toString();
encodedClientID = encodeids.EncodeRecieverAddress(ClientID);
tabledata = crudforgamespecs.GameList(ClientID);
int currgid;
while(tabledata.next()){
currgid = tabledata.getInt("gid");
gamekies.add(currgid);

encodedgamekies.add(encodeids.EncodeRecieverAddress(Integer.toString(
currgid)));
}
crudforgamespecs.CloseStandardDBConnection();
%>

<%
for(int i = 0 ; i < gamekies.size() ; i++ ){
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

crudforgamespecs.StandardDBConnection();
tabledata =
crudforgamespecs.RetrieveGameSpecs(gamekies.get(i));
tabledata.next();
totalachievements = tabledata.getString("totalachievements");
totalachievements = (totalachievements == null ) ? "0" :
totalachievements;
%>

<!-- Start of Game Elements "Dynamics" -->


<div id="clone-gameheader" class="card" style="display:block">
<div class="card-header">
<div class="float-left d-inline-flex">
<b id="clone-labelgname" class="text-secondary"><%=
tabledata.getString("gamename") %></b>
</div>
</div>
</div>

<div id="details" class="card-header">


<label class="form-check-label" >Client ID :</label><b><%=
encodedClientID %></b><br/>

<label class="form-check-label" >Game token :</label><b><%=


encodedgamekies.get(i) %></b><br/>

<label class="form-check-label" >Company Name :</label><b><%=


tabledata.getString("companyname") %></b><br/>

<label class="form-check-label" >Game Name :</label><b><%=


tabledata.getString("gamename") %></b><br/>

<label class="form-check-label" >Total Achievements


:</label><b><%= totalachievements%></b><br/>

<label class="form-check-label" >Total Levels :</label><b><%=


tabledata.getString("totallevels") %></b><br/>

<label class="form-check-label" >Game Genre :</label>

<%
tabledata =
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

crudforgamespecs.RetrieveGenre(gamekies.get(i));
while(tabledata.next()){
%>
<b><%= tabledata.getString("genre") %></b>
<%
}
%>

<br/>
<label class="form-check-label" >Game Platform</label>
<%
tabledata =
crudforgamespecs.RetrievePlatform(gamekies.get(i));
while(tabledata.next()){
%>
<b><%= tabledata.getString("platform") %></b>
<%
}
%>
<br/>

</div>

<div class="card-body" style="display:block">


<!-- Start of Achievement list "Nested-Dynamics" -->
<label class="form-text"><b>Achievements</b></label>
<table class="table table-hover table-responsive-md">
<tbody id="<%= "table-" + gamekies.get(i) %>">

<%
tabledata =
crudforgamespecs.RetrieveAchievements(gamekies.get(i));
while(tabledata.next()){
%>
<tr style="display:block">
<td style="width: 10%">
<input type="text" value="<%=
tabledata.getInt("ano") %>" class="form-control form-control-sm"
disabled />
</td>
<td style="width: 25%">
<input type="text" id="<%= "0-" + gamekies.get(i) +
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

"-" + tabledata.getInt("ano")%>" value="<%=


tabledata.getString("achievementname") %>" placeholder="Name"
class="form-control form-control-sm onchangeAchievements"/>
</td>
<td style="width: 50%">
<input type="text" id="<%= "1-" + gamekies.get(i) +
"-" + tabledata.getInt("ano")%>" value="<%=
tabledata.getString("achievementdesc") %>" placeholder="Description"
class="form-control form-control-sm onchangeAchievements" />
</td>
<td style="width: 15%">
<input type="text" value="<%=
tabledata.getInt("achievementxp") %>" placeholder="xp" class="form-
control form-control-sm " disabled/>
</td>
</tr>

<%
}
totalachievements = "0";
%>
</tbody>
</table>
<!-- End of Achievement list "Nested-Dynamics" -->
</div>

<%
crudforgamespecs.CloseStandardDBConnection();
}
%>
</div>

<!-- Template Input -->


<div style="display:none" id="template-">
<input type="number" id="ano-" class="form-control form-control-sm "
disabled/>
<br/>
<input type="text" id="achname-" placeholder="Achievement Name"
class="form-control form-control-sm "/>
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

<br/>
<input type="text" id="achdesc-" placeholder="Achievement
Description" class="form-control form-control-sm "/>
<br/>
<input type="number" id="achxp-" class="form-control form-control-sm
" />

<button name="Submit" id="save-" class="btn btn-primary


onsave">Save</button><br/>
<button name="Addmore" id="addmore-" class="btn btn-primary
addmore">AddMore</button>
<button name="delete" id="delete-" class="btn btn-primary
delte">Delete</button>
</div>
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

UserRegistration.java
package com.gamersweb.servlets;
import java.io.IOException;

import javax.mail.*;
import java.io.PrintWriter;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet(description = "it validates and stores the data coming


from sign up page", urlPatterns = { "/UserRegistrationForm" })
public class UserRegistrationForm extends HttpServlet {
private static final long serialVersionUID = 1L;

OracleConnection oraconn;
PrintWriter httpresponsedata;
HttpServletRequest request;
HttpServletResponse response;
String emailtovalidate;
crudOperations crudquery;
emailposting postemail;
EnDecoding endecoding;

String encodedEmail;
String encodedKey;
String emailaddress;
String username;
String location;
String password;
String dob;
String GeneratedId;

public UserRegistrationForm() throws SQLException {

super();
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

try {
endecoding = new EnDecoding();
postemail = new emailposting();
crudquery = new crudOperations();
}
catch(MessagingException e) {e.printStackTrace();}
}

protected void doPost(HttpServletRequest request,


HttpServletResponse response) throws ServletException, IOException {
this.request = request;
this.response = response;
httpresponsedata = response.getWriter();
emailaddress = request.getParameter("email");
username = request.getParameter("username");
password = request.getParameter("password");

try {
if(crudquery.ValidationOfEmailAndUsernameDuplicacy(emailaddress ,
username)){
encodedEmail =
endecoding.EncodeRecieverAddress(emailaddress);
int GeneratedId =
crudquery.InsertionOfAccountCredential(username , emailaddress ,
password);
encodedKey =
endecoding.EncodeRecieverAddress(Integer.toString(GeneratedId));

postemail.emailDispatchingProcedure(emailaddress , encodedEmail
,"Get verified your email address" , encodedKey,
emailposting.weblink.VerifiedEmailListener);
httpresponsedata.print("your email has been
successfully registered");
}
else {
httpresponsedata.print("This email or username
is unavailable");
System.out.println("This email or username is
unavailable");} }
catch(SQLException e) {e.printStackTrace();}
catch(MessagingException e) {e.printStackTrace();}
T.Y. Bachelor Of Computer Application (B.C.A) YCMOU

} }

Bibliography
https://stackoverflow.com/
https://developers.google.com/identity/sign-in/web/sign-in
https://console.developers.google.com
https://developer.paypal.com
https://www.tutorialspoint.com/java/index.htm
https://www.javatpoint.com/
https://www.w3schools.com/
https://developer.mozilla.org/
https://materializecss.com/
https://github.com/thashimalayaratnam/Bomberman-Game---Unity/

You might also like