Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Krishna Vemulavada
/
vera_2.1_app
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
708eda49
authored
Oct 12, 2019
by
Simhachalam ch
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
added socket id to chat log table
parent
9508e0fd
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
39 additions
and
12 deletions
app/src/main/java/com/vsoft/vera/CatalogueApplication.java
app/src/main/java/com/vsoft/vera/db/DBConstants.java
app/src/main/java/com/vsoft/vera/db/DBManager.java
app/src/main/java/com/vsoft/vera/db/managers/ChatLogManager.java
app/src/main/java/com/vsoft/vera/ui/ChatActivity.java
app/src/main/java/com/vsoft/vera/utils/ChatLog.java
app/src/main/java/com/vsoft/vera/CatalogueApplication.java
View file @
708eda49
...
...
@@ -156,6 +156,7 @@ public class CatalogueApplication extends MultiDexApplication {
options
.
upgrade
=
true
;
mSocket
=
IO
.
socket
(
Constants
.
CHAT_SERVER_URL
,
options
);
// mSocket = IO.socket("http://10.1.8.229:12811",options);
}
catch
(
URISyntaxException
e
)
{
throw
new
RuntimeException
(
e
);
...
...
app/src/main/java/com/vsoft/vera/db/DBConstants.java
View file @
708eda49
...
...
@@ -46,9 +46,10 @@ public interface DBConstants {
*/
String
CHAT_ID
=
"chat_id"
;
String
CHAT_CLIENT_MESSAGE
=
"client_message"
;
String
CHAT_SERVER__RESPONSE
=
"title"
;
String
CHAT_TIMESTAMP
=
"description"
;
String
CHAT_CONN_STATUS
=
"icon"
;
String
CHAT_SERVER__RESPONSE
=
"server_response"
;
String
CHAT_TIMESTAMP
=
"timestamp"
;
String
CHAT_CONN_STATUS
=
"conn_status"
;
String
CHAT_SOCKET_ID
=
"socket_id"
;
/**
* Catalogue table
...
...
app/src/main/java/com/vsoft/vera/db/DBManager.java
View file @
708eda49
...
...
@@ -83,7 +83,8 @@ public class DBManager extends SQLiteOpenHelper implements DBConstants {
+
CHAT_CLIENT_MESSAGE
+
" text, "
+
CHAT_SERVER__RESPONSE
+
" text, "
+
CHAT_TIMESTAMP
+
" text, "
+
CHAT_CONN_STATUS
+
" text"
+
CHAT_CONN_STATUS
+
" text, "
+
CHAT_SOCKET_ID
+
" text"
+
");"
);
}
...
...
app/src/main/java/com/vsoft/vera/db/managers/ChatLogManager.java
View file @
708eda49
...
...
@@ -47,6 +47,7 @@ public class ChatLogManager implements DBConstants {
chatLog
.
setServerResponse
(
c
.
getString
(
2
));
chatLog
.
setTimestamp
(
c
.
getString
(
3
));
chatLog
.
setConnStatus
(
c
.
getString
(
4
));
chatLog
.
setSocketConnId
(
c
.
getString
(
5
));
chatLogList
.
add
(
chatLog
);
}
...
...
@@ -67,12 +68,13 @@ public class ChatLogManager implements DBConstants {
}
return
-
1
;
}
public
static
void
saveLogEvent
(
String
clientMsg
,
String
serverMsg
,
String
connStatus
,
Date
timestamp
){
public
static
void
saveLogEvent
(
String
clientMsg
,
String
serverMsg
,
String
connStatus
,
String
connId
,
Date
timestamp
){
ChatLog
chatLog
=
new
ChatLog
();
chatLog
.
setTimestamp
(
Util
.
getDateTime
(
timestamp
.
getTime
()));
chatLog
.
setServerResponse
(
serverMsg
);
chatLog
.
setClientMessage
(
clientMsg
);
chatLog
.
setConnStatus
(
connStatus
);
chatLog
.
setSocketConnId
(
connId
);
ChatLogManager
.
save
(
chatLog
);
}
private
static
ContentValues
getChatLogContentValues
(
ChatLog
chatLog
)
{
...
...
@@ -81,6 +83,7 @@ public class ChatLogManager implements DBConstants {
cv
.
put
(
CHAT_SERVER__RESPONSE
,
chatLog
.
getServerResponse
());
cv
.
put
(
CHAT_TIMESTAMP
,
chatLog
.
getTimestamp
());
cv
.
put
(
CHAT_CONN_STATUS
,
chatLog
.
getConnStatus
());
cv
.
put
(
CHAT_SOCKET_ID
,
chatLog
.
getSocketConnId
());
return
cv
;
}
}
\ No newline at end of file
app/src/main/java/com/vsoft/vera/ui/ChatActivity.java
View file @
708eda49
...
...
@@ -601,6 +601,8 @@ public class ChatActivity extends AppCompatActivity implements OnDSListener, OnD
exportAndSaveLogs
(
chatLogList
);
//delete all logs
ChatLogManager
.
deleteAllRows
();
Toast
.
makeText
(
getApplicationContext
(),
"Export Completed. Check in your external storage."
,
Toast
.
LENGTH_LONG
).
show
();
return
true
;
/* case R.id.text_menu_icon:
...
...
@@ -636,11 +638,11 @@ public class ChatActivity extends AppCompatActivity implements OnDSListener, OnD
}
else
{
try
{
writer
=
new
CSVWriter
(
new
FileWriter
(
filePath
));
String
[]
headerLine
=
{
"Chat Id"
,
"Client Msg"
,
"Server Msg"
,
"Conn Status"
,
"Time Stamp
"
}
;
String
[]
headerLine
=
{
"Chat Id"
,
"Time Stamp"
,
"Conn Status"
,
"Socket Id"
,
"Client Msg"
,
"Server Msg
"
}
;
writer
.
writeNext
(
headerLine
);
for
(
ChatLog
chat:
chatLogList
)
{
String
[]
line
=
{
""
+
chat
.
getChatId
(),
chat
.
get
ClientMessage
(),
chat
.
getServerResponse
(),
chat
.
getConnStatus
(),
chat
.
getTimestamp
()
}
;
String
[]
line
=
{
""
+
chat
.
getChatId
(),
chat
.
get
Timestamp
()
,
chat
.
getConnStatus
(),
chat
.
getSocketConnId
(),
chat
.
getClientMessage
(),
chat
.
getServerResponse
()
}
;
writer
.
writeNext
(
line
);
}
writer
.
close
();
...
...
@@ -760,7 +762,7 @@ public class ChatActivity extends AppCompatActivity implements OnDSListener, OnD
Log
.
i
(
"Print"
,
jsonObject
.
toString
());
mSocket
.
emit
(
NEW_MESSAGE
,
jsonObject
);
ChatLogManager
.
saveLogEvent
(
message
,
""
,
"true"
,
new
Date
());
ChatLogManager
.
saveLogEvent
(
message
,
""
,
String
.
valueOf
(
mSocket
.
connected
()),
mSocket
.
id
()
,
new
Date
());
}
else
{
mInputMessageView
.
requestFocus
();
...
...
@@ -801,10 +803,11 @@ public class ChatActivity extends AppCompatActivity implements OnDSListener, OnD
@Override
public
void
run
()
{
// userAuthenticateTask();
Log
.
e
(
TAG
,
"socket got connected"
);
Log
.
e
(
TAG
,
"socket got connected"
+
mSocket
.
id
()
);
// Toast.makeText(getApplicationContext(),
// R.string.connect, Toast.LENGTH_LONG).show();
initChatMessage
(
INIT_MSG
);
ChatLogManager
.
saveLogEvent
(
"New Connection Created"
,
""
,
"true"
,
mSocket
.
id
(),
new
Date
());
}
});
}
...
...
@@ -872,6 +875,8 @@ public class ChatActivity extends AppCompatActivity implements OnDSListener, OnD
private
Emitter
.
Listener
onDisconnect
=
new
Emitter
.
Listener
()
{
@Override
public
void
call
(
Object
...
args
)
{
ChatLogManager
.
saveLogEvent
(
"Connection Disconnected"
,
""
,
String
.
valueOf
(
mSocket
.
connected
()),
mSocket
.
id
(),
new
Date
());
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
...
...
@@ -903,6 +908,8 @@ public class ChatActivity extends AppCompatActivity implements OnDSListener, OnD
@Override
public
void
call
(
Object
...
args
)
{
Log
.
e
(
TAG
,
"onConnectTimeOut Called"
);
ChatLogManager
.
saveLogEvent
(
"Connection Timed Out"
,
""
,
String
.
valueOf
(
mSocket
.
connected
()),
mSocket
.
id
(),
new
Date
());
// Toast.makeText(getApplicationContext(),
// "onConnectTimeOut Called", Toast.LENGTH_LONG).show();
//reconnect();
...
...
@@ -916,6 +923,8 @@ public class ChatActivity extends AppCompatActivity implements OnDSListener, OnD
@Override
public
void
call
(
Object
...
args
)
{
Log
.
e
(
TAG
,
"Reconnection Called"
);
ChatLogManager
.
saveLogEvent
(
"Reconnection Called"
,
""
,
String
.
valueOf
(
mSocket
.
connected
()),
mSocket
.
id
(),
new
Date
());
// Toast.makeText(getApplicationContext(),
// "Reconnection Called", Toast.LENGTH_LONG).show();
...
...
@@ -929,11 +938,13 @@ public class ChatActivity extends AppCompatActivity implements OnDSListener, OnD
private
Emitter
.
Listener
onConnectError
=
new
Emitter
.
Listener
()
{
@Override
public
void
call
(
Object
...
args
)
{
ChatLogManager
.
saveLogEvent
(
"Failed create a socket connection"
,
""
,
String
.
valueOf
(
mSocket
.
connected
()),
mSocket
.
id
(),
new
Date
());
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(!
isConnectError
)
{
Log
.
e
(
TAG
,
"failed to connect"
);
Snackbar
snackbar
=
Snackbar
.
make
(
mMessagesView
,
R
.
string
.
error_connect
,
Snackbar
.
LENGTH_LONG
)
.
setAction
(
"Dismiss"
,
new
View
.
OnClickListener
()
{
...
...
@@ -1024,7 +1035,7 @@ public class ChatActivity extends AppCompatActivity implements OnDSListener, OnD
}
if
(!
message
.
isEmpty
())
{
ChatLogManager
.
saveLogEvent
(
""
,
message
,
"true"
,
new
Date
());
ChatLogManager
.
saveLogEvent
(
""
,
message
,
String
.
valueOf
(
mSocket
.
connected
()),
mSocket
.
id
()
,
new
Date
());
if
(
message
.
contains
(
Constants
.
RESET_PASSWORD_NAVIGATION_SCREEN
)){
runOnUiThread
(
new
Runnable
()
{
...
...
app/src/main/java/com/vsoft/vera/utils/ChatLog.java
View file @
708eda49
...
...
@@ -2,9 +2,11 @@ package com.vsoft.vera.utils;
public
class
ChatLog
{
private
Long
chatId
;
/**
* socket connection id
*/
private
String
socketConnId
;
private
String
serverResponse
;
private
String
timestamp
;
/**
...
...
@@ -14,6 +16,13 @@ public class ChatLog {
private
String
connStatus
;
private
String
clientMessage
;
public
String
getSocketConnId
()
{
return
socketConnId
;
}
public
void
setSocketConnId
(
String
socketConnId
)
{
this
.
socketConnId
=
socketConnId
;
}
public
Long
getChatId
()
{
return
chatId
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment