Merge branch 'master'
This commit is contained in:
2
Android/BewoKlientenApp/.idea/compiler.xml
generated
2
Android/BewoKlientenApp/.idea/compiler.xml
generated
@@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<option name="DEFAULT_COMPILER" value="Javac" />
|
||||
<resourceExtensions />
|
||||
<wildcardResourcePatterns>
|
||||
<entry name="!?*.java" />
|
||||
@@ -12,6 +11,7 @@
|
||||
<entry name="!?*.flex" />
|
||||
<entry name="!?*.kt" />
|
||||
<entry name="!?*.clj" />
|
||||
<entry name="!?*.aj" />
|
||||
</wildcardResourcePatterns>
|
||||
<annotationProcessing>
|
||||
<profile default="true" name="Default" enabled="false">
|
||||
|
||||
29
Android/BewoKlientenApp/.idea/misc.xml
generated
29
Android/BewoKlientenApp/.idea/misc.xml
generated
@@ -1,29 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="NullableNotNullManager">
|
||||
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
|
||||
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
|
||||
<option name="myNullables">
|
||||
<value>
|
||||
<list size="4">
|
||||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
|
||||
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
|
||||
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
|
||||
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
<option name="myNotNulls">
|
||||
<value>
|
||||
<list size="4">
|
||||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
|
||||
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
|
||||
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
|
||||
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
|
||||
<OptionsSetting value="true" id="Add" />
|
||||
<OptionsSetting value="true" id="Remove" />
|
||||
@@ -34,13 +10,10 @@
|
||||
<ConfirmationsSetting value="0" id="Add" />
|
||||
<ConfirmationsSetting value="0" id="Remove" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="Android" />
|
||||
</component>
|
||||
<component name="SvnBranchConfigurationManager">
|
||||
<option name="mySupportsUserInfoFilter" value="true" />
|
||||
</component>
|
||||
</project>
|
||||
6
Android/BewoKlientenApp/.idea/vcs.xml
generated
6
Android/BewoKlientenApp/.idea/vcs.xml
generated
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="svn" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -110,5 +110,6 @@
|
||||
<orderEntry type="library" exported="" name="appcompat-v7-21.0.3" level="project" />
|
||||
<orderEntry type="library" exported="" name="support-v4-21.0.3" level="project" />
|
||||
<orderEntry type="library" exported="" name="support-annotations-21.0.3" level="project" />
|
||||
<orderEntry type="library" exported="" name="android-android-21" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -5,7 +5,7 @@ buildscript {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:2.1.0'
|
||||
classpath 'com.android.tools.build:gradle:2.1.2'
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
}
|
||||
|
||||
2
Android/BewoMitarbeiterApp/.idea/misc.xml
generated
2
Android/BewoMitarbeiterApp/.idea/misc.xml
generated
@@ -37,7 +37,7 @@
|
||||
<ConfirmationsSetting value="0" id="Add" />
|
||||
<ConfirmationsSetting value="0" id="Remove" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
||||
@@ -82,7 +82,6 @@
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
|
||||
@@ -115,8 +114,8 @@
|
||||
<orderEntry type="library" exported="" name="support-v4-21.0.3" level="project" />
|
||||
<orderEntry type="library" exported="" name="support-annotations-21.0.3" level="project" />
|
||||
<orderEntry type="library" exported="" name="commons-lang3-3.3.2" level="project" />
|
||||
<orderEntry type="library" exported="" name="commons-io-1.3.2" level="project" />
|
||||
<orderEntry type="library" exported="" name="robospice-1.4.14" level="project" />
|
||||
<orderEntry type="library" exported="" name="commons-io-1.3.2" level="project" />
|
||||
<orderEntry type="library" exported="" name="robospice-cache-1.4.14" level="project" />
|
||||
<orderEntry type="module" module-name="volley" exported="" />
|
||||
<orderEntry type="library" exported="" name="android-android-21" level="project" />
|
||||
|
||||
@@ -62,8 +62,8 @@
|
||||
android:name=".LoginActivity"
|
||||
android:label="@string/title_activity_login">
|
||||
</activity>
|
||||
<activity android:name=".TokenActivity">
|
||||
</activity>
|
||||
<!--<activity android:name=".TokenActivity">
|
||||
</activity>-->
|
||||
|
||||
<service
|
||||
android:name="com.octo.android.robospice.UncachedSpiceService"
|
||||
|
||||
@@ -42,21 +42,13 @@ import com.octo.android.robospice.request.listener.RequestListener;
|
||||
|
||||
import org.ksoap2.serialization.SoapPrimitive;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.Type;
|
||||
import java.net.Socket;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
@@ -68,47 +60,40 @@ import entities.ChatMessage;
|
||||
import soapConnection.DataIdentifier;
|
||||
import soapConnection.Packet;
|
||||
|
||||
import soapConnection.SoapConnectionManager;
|
||||
import tcpConnection.SocketManager;
|
||||
import tcpConnection.UIHandler;
|
||||
import util.SecurityUtils;
|
||||
import util.Util;
|
||||
|
||||
/**
|
||||
* Created by bib on 03.05.2016.
|
||||
*/
|
||||
public class ChatActivity extends ActionBarActivity{
|
||||
|
||||
public class ChatActivity extends ActionBarActivity {
|
||||
private static final String LOG_TAG = "CHAT";
|
||||
|
||||
private DatabaseHandler databaseHandler;
|
||||
|
||||
//View Variablen
|
||||
protected TextView chat;
|
||||
protected EditText text;
|
||||
protected Button senden;
|
||||
|
||||
//Server Variablen
|
||||
public static Socket socket;
|
||||
DataOutputStream socketOutputStream;
|
||||
|
||||
String saveCompleteMessage;
|
||||
|
||||
//Design View
|
||||
protected ListView listView;
|
||||
public static List<ChatMessage> chatMessages;
|
||||
public static ArrayAdapter<ChatMessage> adapter;
|
||||
public static ChatMessageFormat chatMessage;
|
||||
|
||||
File file;
|
||||
File UnsentFile = null;
|
||||
|
||||
protected String recipientName;
|
||||
protected int recipientPersonOid;
|
||||
|
||||
private SpiceManager spiceManager = new SpiceManager(UncachedSpiceService.class);
|
||||
|
||||
private UIHandler chatUIHandler;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.chat);
|
||||
|
||||
ActionBar action = getSupportActionBar();
|
||||
@@ -119,11 +104,9 @@ public class ChatActivity extends ActionBarActivity{
|
||||
LayoutInflater inflate = LayoutInflater.from(this);
|
||||
View mCustomView = inflate.inflate(R.layout.custom_menuebar, null);
|
||||
|
||||
// Initialiesiere die Variablen
|
||||
TextView titlename = (TextView)mCustomView.findViewById(R.id.PersonalName);
|
||||
ImageView titlepic = (ImageView)mCustomView.findViewById(R.id.PersonalPic);
|
||||
|
||||
//get Daten aus vorheriger Activity
|
||||
Bundle zielkorb = getIntent().getExtras();
|
||||
recipientName = zielkorb.getString("Name");
|
||||
recipientPersonOid = zielkorb.getInt("RecipientOid");
|
||||
@@ -131,7 +114,6 @@ public class ChatActivity extends ActionBarActivity{
|
||||
byte[] bildArray = zielkorb.getByteArray("Bild");
|
||||
Bitmap customerImage;
|
||||
|
||||
//ein try catch wäre vorteilhaft || Später
|
||||
if(bildArray != null) {
|
||||
customerImage = BitmapFactory.decodeByteArray(bildArray, 0, bildArray.length);
|
||||
titlepic.setImageBitmap(GetCircleBitmap(customerImage));
|
||||
@@ -155,280 +137,113 @@ public class ChatActivity extends ActionBarActivity{
|
||||
adapter = new MessageAdapter(this, R.layout.item_chat_left, chatMessages);
|
||||
listView.setAdapter(adapter);
|
||||
|
||||
try {
|
||||
socket = MainActivityMitarbeiter.socket;
|
||||
chatUIHandler = new UIHandler() {
|
||||
@Override
|
||||
public void updateUserInterface(final Packet chatPacket) {
|
||||
try {
|
||||
switch(chatPacket.ChatDataIdentifier) {
|
||||
case MESSAGE:
|
||||
listView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
chatPacket.writeToLog();
|
||||
|
||||
MainActivityMitarbeiter.CloseMainActivitySocketListener();
|
||||
ChatMessage message = new ChatMessage(chatPacket.SenderPersonOid, chatPacket.RecipientPersonOid, chatPacket.MessageTimeStamp, chatPacket.ChatMessage, false, chatPacket.ServerseitigeOid);
|
||||
|
||||
socketOutputStream = new DataOutputStream(socket.getOutputStream());
|
||||
} catch(Exception e){
|
||||
Log.e("CHAT_ERROR", "Fehler bei der Socket-Erstellung: " + e.getMessage());
|
||||
}
|
||||
databaseHandler.addChatMessage(message);
|
||||
|
||||
//ReadMessageToStorage();
|
||||
chatMessages.add(message);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
break;
|
||||
case MESSAGE_RESPONSE:
|
||||
ChatMessage cm = databaseHandler.getChatMessageById(chatPacket.ClientseitigeOid);
|
||||
|
||||
cm.ServerseitigeOid = chatPacket.ServerseitigeOid;
|
||||
|
||||
databaseHandler.updateChatMessage(cm);
|
||||
|
||||
break;
|
||||
}
|
||||
} catch(Exception pe) {
|
||||
pe.printStackTrace();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
text = (EditText)findViewById(R.id.editText);
|
||||
|
||||
senden.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
if(!text.getText().toString().isEmpty()) {
|
||||
new Thread(new MessageSender()).start();
|
||||
} else {
|
||||
Toast.makeText(ChatActivity.this, "Sie müssen schon Text eingeben ", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Thread t1 = new Thread(new RequestSender());
|
||||
t1.start();
|
||||
|
||||
Thread t = new Thread(new SocketListener());
|
||||
t.start();
|
||||
}
|
||||
|
||||
public class RequestSender implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if(socket != null ) {
|
||||
Packet p = new Packet();
|
||||
//p.ChatMessage = text.getText().toString(); // Hier Datum von bis?
|
||||
p.ChatDataIdentifier = DataIdentifier.OLD_MESSAGE;
|
||||
p.RecipientPersonOid = recipientPersonOid;
|
||||
|
||||
SharedPreferences settings = getSharedPreferences(Util.PREFS_NAME, 0);
|
||||
|
||||
byte[] tenantByteArray = Base64.decode(settings.getString(Util.PREFS_TENANT_KEY, null), Base64.DEFAULT);
|
||||
ByteArrayInputStream tenantStream = new ByteArrayInputStream(tenantByteArray);
|
||||
|
||||
p.Tenant = SecurityUtils.decrypt(tenantStream).toString();
|
||||
|
||||
socketOutputStream.write(p.GetDataStream());
|
||||
socketOutputStream.flush();
|
||||
}
|
||||
} catch(IOException s){
|
||||
Log.v("Status: ","Senden einer Anfrage, alle vergangenen Nachrichten zu laden konnte nicht ausgeführt werden.");
|
||||
|
||||
s.printStackTrace();
|
||||
} catch (NoSuchPaddingException | InvalidAlgorithmParameterException | NoSuchAlgorithmException | InvalidKeyException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class MessageSender implements Runnable{
|
||||
public void run(){
|
||||
try{
|
||||
if(socket != null ) {
|
||||
|
||||
Calendar c = Calendar.getInstance();
|
||||
final Date now = c.getTime();
|
||||
Date now = c.getTime();
|
||||
|
||||
final Packet p = new Packet();
|
||||
p.ChatMessage = text.getText().toString();
|
||||
p.ChatDataIdentifier = DataIdentifier.MESSAGE;
|
||||
p.RecipientPersonOid = recipientPersonOid;
|
||||
p.MessageTimeStamp = now;
|
||||
Packet packet = new Packet();
|
||||
packet.ChatMessage = text.getText().toString();
|
||||
packet.ChatDataIdentifier = DataIdentifier.MESSAGE;
|
||||
packet.RecipientPersonOid = recipientPersonOid;
|
||||
packet.MessageTimeStamp = now;
|
||||
|
||||
SharedPreferences settings = getSharedPreferences(Util.PREFS_NAME, 0);
|
||||
|
||||
byte[] tenantByteArray = Base64.decode(settings.getString(Util.PREFS_TENANT_KEY, null), Base64.DEFAULT);
|
||||
ByteArrayInputStream tenantStream = new ByteArrayInputStream(tenantByteArray);
|
||||
|
||||
p.Tenant = SecurityUtils.decrypt(tenantStream).toString();
|
||||
try {
|
||||
packet.Tenant = SecurityUtils.decrypt(tenantStream).toString();
|
||||
} catch (IOException | NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | InvalidAlgorithmParameterException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
socketOutputStream.write(p.GetDataStream());
|
||||
socketOutputStream.flush();
|
||||
|
||||
|
||||
final ChatMessage message = new ChatMessage(packet.SenderPersonOid, packet.RecipientPersonOid, packet.MessageTimeStamp, packet.ChatMessage, false, 0);
|
||||
|
||||
long coid = databaseHandler.addChatMessage(message);
|
||||
|
||||
packet.ClientseitigeOid = Long.valueOf(coid).intValue();
|
||||
|
||||
packet.writeToLog();
|
||||
|
||||
SocketManager.sendMessage(packet);
|
||||
|
||||
listView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ChatMessage message = new ChatMessage(SoapConnectionManager.User.getPersonOid().intValue(), recipientPersonOid, p.MessageTimeStamp, text.getText().toString(), false, 0);
|
||||
|
||||
databaseHandler.addChatMessage(message);
|
||||
|
||||
chatMessages.add(message);
|
||||
adapter.notifyDataSetChanged();
|
||||
|
||||
text.setText("");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Toast.makeText(ChatActivity.this, "Sie müssen schon Text eingeben ", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
else {
|
||||
Log.i("SEND_CHAT_MESSAGE","Socket ist null");
|
||||
}
|
||||
|
||||
|
||||
}catch(IOException s){
|
||||
Log.v("Status: ","Senden einer Nachricht konnte nicht ausgeführt werden. Save wird ausgeführt");
|
||||
|
||||
SaveAfterLoseConnection(saveCompleteMessage);
|
||||
s.printStackTrace();
|
||||
} catch (NoSuchPaddingException | InvalidAlgorithmParameterException | NoSuchAlgorithmException | InvalidKeyException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
|
||||
ArrayList<Integer> test = databaseHandler.getExistingChatMessageIds();
|
||||
|
||||
for(int id : test) {
|
||||
Log.i("CHATMESSAGE-ID", "" + id);
|
||||
}
|
||||
}
|
||||
|
||||
// Erhalte Messages all the time
|
||||
public class SocketListener implements Runnable{
|
||||
Packet chatPacket;
|
||||
@Override
|
||||
public void onResume() {
|
||||
SocketManager.uiHandler = chatUIHandler;
|
||||
|
||||
public void run(){
|
||||
try{
|
||||
while(true){
|
||||
if (socket != null) {
|
||||
if(socket.isConnected()) {
|
||||
final ListView listV = (ListView) findViewById(R.id.list_msg);
|
||||
|
||||
InputStream stream = socket.getInputStream();
|
||||
|
||||
int size = stream.available();
|
||||
|
||||
if(size == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
StringBuilder total = new StringBuilder(stream.available());
|
||||
|
||||
int counter = 0;
|
||||
|
||||
while(counter < size) {
|
||||
|
||||
char c = (char) stream.read();
|
||||
total.append(c);
|
||||
|
||||
counter++;
|
||||
}
|
||||
|
||||
try {
|
||||
chatPacket = new Packet(total.toString());
|
||||
|
||||
if(!chatPacket.ChatDataIdentifier.equals(DataIdentifier.MESSAGE)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
chatPacket.WriteToLog();
|
||||
|
||||
listV.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
ChatMessage message = new ChatMessage(chatPacket.SenderPersonOid, chatPacket.RecipientPersonOid, chatPacket.MessageTimeStamp, chatPacket.ChatMessage, false, chatPacket.ServerseitigeOid);
|
||||
|
||||
databaseHandler.addChatMessage(message);
|
||||
|
||||
chatMessages.add(message);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
} catch(Exception pe) {
|
||||
Log.e("CONVERTING JSON: ", pe.getMessage());
|
||||
}
|
||||
} else {
|
||||
Log.i("SOCKETLISTENER/CHAT", "Nicht mit dem Socket verbunden");
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch(Exception e) {
|
||||
Log.e("Status ","Verbindung zum Server wurde seitens dem Server getrennt: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
public void SaveAfterLoseConnection(String UnsendMessage){
|
||||
CreateCustomFileForUnsentMessage();
|
||||
try{
|
||||
FileOutputStream stream = new FileOutputStream(UnsentFile,true);
|
||||
public void onDestroy(){
|
||||
Log.i("CHAT_ON_DESTROY", "Zerstöre...");
|
||||
|
||||
try{
|
||||
stream.write(UnsendMessage.getBytes());
|
||||
}finally {
|
||||
stream.close();
|
||||
}
|
||||
}catch (Exception e){
|
||||
Log.v("Fehler",e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void SendAfterGetConnection(){
|
||||
//ist eine UnsendMessage File vorhanden
|
||||
if(UnsentFile != null && socket.isConnected()){
|
||||
try{
|
||||
FileInputStream stream = new FileInputStream(UnsentFile);
|
||||
InputStreamReader in = new InputStreamReader(stream);
|
||||
BufferedReader readLn = new BufferedReader(in);
|
||||
|
||||
String line = readLn.readLine();
|
||||
String allLines="";
|
||||
|
||||
while (line != null) {
|
||||
allLines += line;
|
||||
|
||||
String[] splitt = line.split("/");
|
||||
|
||||
if(splitt.length >1 ) {
|
||||
String[] ArtDate = splitt[1].split("%");
|
||||
|
||||
final String message = splitt[0];
|
||||
final boolean art = Boolean.valueOf(ArtDate[0]);
|
||||
final String datetime = ArtDate[1];
|
||||
|
||||
//für jede Gelesene Line Sende Nachricht
|
||||
new Thread(new SendUnsentMessage(message)).start();
|
||||
}
|
||||
line = readLn.readLine();
|
||||
}
|
||||
stream.close();
|
||||
in.close();
|
||||
UnsentFile.delete();
|
||||
}catch(Exception fe){
|
||||
Log.v("Status","Ein problem ist im BEreich Unsend Ms Aufgetreten");
|
||||
}
|
||||
//recreate();
|
||||
}
|
||||
}
|
||||
|
||||
public class SendUnsentMessage implements Runnable{
|
||||
|
||||
String al;
|
||||
|
||||
SendUnsentMessage(String unMS){
|
||||
this.al = unMS;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
|
||||
byte[] ts = al.getBytes();
|
||||
try {
|
||||
if (socket != null && socketOutputStream != null) {
|
||||
|
||||
//try catch bei catch SaveAfterLoseConnection();
|
||||
socketOutputStream.write(ts);
|
||||
socketOutputStream.flush();
|
||||
}
|
||||
}catch(Exception xs){
|
||||
Log.e("SendUnsentMessage", xs.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void CreateCustomFileForUnsentMessage(){
|
||||
try{
|
||||
File pfad = getBaseContext().getFilesDir();
|
||||
|
||||
//Für external Save
|
||||
//File pfad = getBaseContext().getExternalFilesDir(null);
|
||||
|
||||
//Erstelle das File Objekt
|
||||
UnsentFile = new File(pfad,recipientName+"_Unsend"+".txt");
|
||||
|
||||
}catch(Exception e){
|
||||
Log.v("Fehler"," Das erstellen/öffnen einer Datei ist Derzeit nicht möglich");
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
|
||||
@@ -75,12 +75,10 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
||||
db.execSQL(createChatMessageTable);
|
||||
}
|
||||
|
||||
void addChatMessage(ChatMessage message) {
|
||||
long addChatMessage(ChatMessage message) {
|
||||
SQLiteDatabase db = this.getWritableDatabase();
|
||||
ContentValues values = new ContentValues();
|
||||
|
||||
Log.i("ZEIT_CHECK_DB", getDateTimeString(message.InsTs));
|
||||
|
||||
values.put(KEY_SENDER_PERSON_OID_CHATMESSAGE, message.SenderPersonOid);
|
||||
values.put(KEY_RECIPIENT_PERSON_OID_CHATMESSAGE, message.RecipientPersonOid);
|
||||
values.put(KEY_INSTS_CHATMESSAGE, getDateTimeString(message.InsTs));
|
||||
@@ -89,8 +87,41 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
||||
values.put(KEY_SERVERSEITIGE_OID_CHATMESSAGE, message.ServerseitigeOid);
|
||||
|
||||
long rowId = db.insert(TABLE_CHATMESSAGE, null, values);
|
||||
Log.i("CHAT_MESSAGE_INSERT", "RowID: " + rowId);
|
||||
db.close();
|
||||
|
||||
return rowId;
|
||||
}
|
||||
|
||||
void updateChatMessage(ChatMessage message) {
|
||||
SQLiteDatabase db = this.getWritableDatabase();
|
||||
ContentValues values = new ContentValues();
|
||||
|
||||
values.put(KEY_SENDER_PERSON_OID_CHATMESSAGE, message.SenderPersonOid);
|
||||
values.put(KEY_RECIPIENT_PERSON_OID_CHATMESSAGE, message.RecipientPersonOid);
|
||||
values.put(KEY_INSTS_CHATMESSAGE, getDateTimeString(message.InsTs));
|
||||
values.put(KEY_CHAT_TEXT_CHATMESSAGE, message.ChatText);
|
||||
values.put(KEY_IS_DELIVERED_CHATMESSAGE, (message.IsDelivered ? 1 : 0));
|
||||
values.put(KEY_SERVERSEITIGE_OID_CHATMESSAGE, message.ServerseitigeOid);
|
||||
|
||||
db.update(TABLE_CHATMESSAGE, values, KEY_ID_CHATMESSAGE + " = ?", new String[] { String.valueOf(message.Id)});
|
||||
}
|
||||
|
||||
ArrayList<Integer> getExistingChatMessageIds() {
|
||||
ArrayList<Integer> result = new ArrayList<Integer>();
|
||||
|
||||
SQLiteDatabase db = this.getWritableDatabase();
|
||||
|
||||
String selectQuery = "SELECT "+ KEY_SERVERSEITIGE_OID_CHATMESSAGE + " FROM " + TABLE_CHATMESSAGE + " WHERE " + KEY_SERVERSEITIGE_OID_CHATMESSAGE + " <> 0";
|
||||
|
||||
Cursor cursor = db.rawQuery(selectQuery, null);
|
||||
|
||||
if(cursor.moveToFirst()) {
|
||||
do {
|
||||
result.add(cursor.getInt(0));
|
||||
} while(cursor.moveToNext());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private String getDateTimeString(Date date) {
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by bib on 03.05.2016.
|
||||
@@ -30,15 +31,20 @@ import java.io.InputStreamReader;
|
||||
public class KontaktAdapter extends ArrayAdapter<ContactListItem> {
|
||||
|
||||
private final Context context;
|
||||
private final ContactListItem[] values;
|
||||
public final ArrayList<ContactListItem> values;
|
||||
|
||||
private Bitmap bitmaping;
|
||||
ImageView imageView;
|
||||
|
||||
public void setMinitext(TextView minitext) {
|
||||
this.minitext = minitext;
|
||||
}
|
||||
|
||||
TextView minitext;
|
||||
|
||||
Thread getPic;
|
||||
|
||||
public KontaktAdapter(Context context, ContactListItem[] values) {
|
||||
public KontaktAdapter(Context context, ArrayList<ContactListItem> values) {
|
||||
super(context, R.layout.kontakt_list_chat, values);
|
||||
this.context = context;
|
||||
this.values = values;
|
||||
@@ -55,7 +61,7 @@ public class KontaktAdapter extends ArrayAdapter<ContactListItem> {
|
||||
ImageView onlinestats = (ImageView)rowView.findViewById(R.id.status);
|
||||
imageView = (ImageView) rowView.findViewById(R.id.logo);
|
||||
|
||||
textView.setText(values[position].getChatName());
|
||||
textView.setText(values.get(position).getChatName());
|
||||
|
||||
|
||||
// if(values[position].getChatName().equals("Demo")) {
|
||||
@@ -66,10 +72,10 @@ public class KontaktAdapter extends ArrayAdapter<ContactListItem> {
|
||||
// }
|
||||
|
||||
//ab hier fehlerhaft
|
||||
if(values[position].getPicture() != null) {
|
||||
if(values.get(position).getPicture() != null) {
|
||||
|
||||
//Konvert byte[] to Image
|
||||
Bitmap i = BitmapFactory.decodeByteArray(values[position].getPicture(),0,values[position].getPicture().length);
|
||||
Bitmap i = BitmapFactory.decodeByteArray(values.get(position).getPicture(),0,values.get(position).getPicture().length);
|
||||
|
||||
|
||||
|
||||
@@ -104,7 +110,7 @@ public class KontaktAdapter extends ArrayAdapter<ContactListItem> {
|
||||
// else if(values[position].getArt().equals("3"))
|
||||
// onlinestats.setImageResource(R.drawable.offline);
|
||||
|
||||
onlinestats.setImageResource((values[position].isOnline ? R.drawable.online : R.drawable.offline));
|
||||
onlinestats.setImageResource((values.get(position).isOnline ? R.drawable.online : R.drawable.offline));
|
||||
|
||||
return rowView;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
package beyondsoft.bewomitarbeiterapp;
|
||||
|
||||
import android.app.ListActivity;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
@@ -27,11 +32,17 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import entities.ChatMessage;
|
||||
import entities.ChatPerson;
|
||||
import soapConnection.DataIdentifier;
|
||||
import soapConnection.JsonSoapPrimitiveRequest;
|
||||
import soapConnection.Packet;
|
||||
import soapConnection.SoapCalls;
|
||||
import soapConnection.SoapConnectionManager;
|
||||
import tcpConnection.SocketManager;
|
||||
import tcpConnection.UIHandler;
|
||||
|
||||
/**
|
||||
* Created by bib on 02.05.2016.
|
||||
@@ -41,7 +52,13 @@ public class KontaktChatActivity extends ListActivity {
|
||||
private SpiceManager spiceManager = new SpiceManager(UncachedSpiceService.class);
|
||||
private DatabaseHandler databaseHandler;
|
||||
|
||||
private ArrayList<Integer> onlinePersonOids = new ArrayList<>();
|
||||
private static ArrayList<Integer> onlinePersonOids = new ArrayList<>();
|
||||
|
||||
private UIHandler kontaktChatUIHandler;
|
||||
|
||||
public static ListView listView;
|
||||
|
||||
ArrayList<ContactListItem> contactList = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -60,6 +77,69 @@ public class KontaktChatActivity extends ListActivity {
|
||||
|
||||
JsonSoapPrimitiveRequest request = new JsonSoapPrimitiveRequest(SoapCalls.GET_CONTACTS_FOR_PERSON, propertyInfos);
|
||||
spiceManager.execute(request, new JsonSoapPrimitiveRequestListener());
|
||||
|
||||
listView = getListView();
|
||||
|
||||
kontaktChatUIHandler = new UIHandler() {
|
||||
@Override
|
||||
public void updateUserInterface(final Packet chatPacket) {
|
||||
try {
|
||||
switch(chatPacket.ChatDataIdentifier) {
|
||||
case MESSAGE:
|
||||
ChatMessage message = new ChatMessage(chatPacket.SenderPersonOid, chatPacket.RecipientPersonOid, chatPacket.MessageTimeStamp, chatPacket.ChatMessage, false, chatPacket.ServerseitigeOid);
|
||||
|
||||
databaseHandler.addChatMessage(message);
|
||||
|
||||
SetNotify(chatPacket.ChatName, chatPacket.ChatMessage, chatPacket.SenderPersonOid);
|
||||
break;
|
||||
case STATUS_NOTIFICATION_LOGIN:
|
||||
if(!onlinePersonOids.contains(chatPacket.SenderPersonOid)) {
|
||||
onlinePersonOids.add(chatPacket.SenderPersonOid);
|
||||
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
KontaktAdapter ka =((KontaktAdapter) listView.getAdapter());
|
||||
|
||||
for(ContactListItem item : ka.values) {
|
||||
if(item.getPersonOid() == chatPacket.SenderPersonOid) {
|
||||
item.isOnline = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ka.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
case STATUS_NOTIFICATION_LOGOUT:
|
||||
if(onlinePersonOids.contains(chatPacket.SenderPersonOid)) {
|
||||
onlinePersonOids.remove(Integer.valueOf(chatPacket.SenderPersonOid));
|
||||
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
KontaktAdapter ka =((KontaktAdapter) listView.getAdapter());
|
||||
|
||||
for(ContactListItem item : ka.values) {
|
||||
if(item.getPersonOid() == chatPacket.SenderPersonOid) {
|
||||
item.isOnline = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ka.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
} catch(Exception pe) {
|
||||
pe.printStackTrace();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -112,6 +192,16 @@ public class KontaktChatActivity extends ListActivity {
|
||||
startActivity(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
SocketManager.uiHandler = kontaktChatUIHandler;
|
||||
|
||||
// Update der Kontaktliste
|
||||
|
||||
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop(){
|
||||
spiceManager.shouldStop();
|
||||
@@ -138,8 +228,6 @@ public class KontaktChatActivity extends ListActivity {
|
||||
Log.i("KONTAKT_CHAT_ACTIVITY", "soapPrimitive ist NULL!");
|
||||
}
|
||||
|
||||
Log.i("SoapPrmitive", "" + soapPrimitive.toString());
|
||||
|
||||
Gson gson = new GsonBuilder().create();
|
||||
|
||||
Type listType = new TypeToken<ArrayList<ChatPerson>>(){}.getType();
|
||||
@@ -160,18 +248,47 @@ public class KontaktChatActivity extends ListActivity {
|
||||
}
|
||||
}
|
||||
|
||||
lc = databaseHandler.getAllContacts();
|
||||
|
||||
for(ContactListItem item : lc) {
|
||||
if(onlinePersonOids.contains(item.getPersonOid())){
|
||||
item.isOnline = true;
|
||||
}
|
||||
}
|
||||
|
||||
ContactListItem[] Klientel = lc.toArray(new ContactListItem[lc.size()]);
|
||||
contactList = new ArrayList<>(lc);
|
||||
|
||||
setListAdapter(new KontaktAdapter(KontaktChatActivity.this, Klientel));
|
||||
setListAdapter(new KontaktAdapter(KontaktChatActivity.this, contactList));
|
||||
databaseHandler.close();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetNotify(String username, String message, int recipientOid){
|
||||
NotificationCompat.Builder mBuilder =
|
||||
new NotificationCompat.Builder(this)
|
||||
.setSmallIcon(R.drawable.ic_stat_name)
|
||||
.setContentTitle(username)
|
||||
.setContentText(message)
|
||||
.setAutoCancel(true)
|
||||
.setDefaults(Notification.DEFAULT_SOUND)
|
||||
.setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 }) //Notification.Default_Vibrate
|
||||
.setLights(Color.YELLOW, 3000, 3000) //Notification.Default_Lights
|
||||
.setOngoing(true);
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("Name", username);
|
||||
bundle.putInt("RecipientOid", recipientOid);
|
||||
|
||||
Intent resultIntent = new Intent(this, ChatActivity.class);
|
||||
resultIntent.putExtras(bundle);
|
||||
|
||||
resultIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
PendingIntent resultPendingIntent = PendingIntent.getActivity(this.getApplicationContext(), 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT );
|
||||
|
||||
NotificationManager mNotifyMgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||
|
||||
mBuilder.setContentIntent(resultPendingIntent);
|
||||
|
||||
Random random = new Random();
|
||||
|
||||
mNotifyMgr.notify(random.nextInt(9999 - 1000) + 1000, mBuilder.build());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,7 @@ package beyondsoft.bewomitarbeiterapp;
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
@@ -28,8 +27,6 @@ import com.android.volley.Response;
|
||||
import com.android.volley.VolleyError;
|
||||
import com.android.volley.toolbox.StringRequest;
|
||||
import com.android.volley.toolbox.Volley;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.octo.android.robospice.SpiceManager;
|
||||
import com.octo.android.robospice.UncachedSpiceService;
|
||||
import com.octo.android.robospice.persistence.exception.SpiceException;
|
||||
@@ -40,6 +37,8 @@ import org.ksoap2.serialization.SoapPrimitive;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.InvalidKeyException;
|
||||
@@ -52,6 +51,7 @@ import soapConnection.ApplicationUser;
|
||||
import soapConnection.JsonSoapPrimitiveRequest;
|
||||
import soapConnection.SoapCalls;
|
||||
import soapConnection.SoapConnectionManager;
|
||||
import tcpConnection.SocketManager;
|
||||
import util.SecurityUtils;
|
||||
import util.Util;
|
||||
|
||||
@@ -75,6 +75,23 @@ public class LoginActivity extends ActionBarActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_login);
|
||||
|
||||
try {
|
||||
FileOutputStream fos = openFileOutput(Util.DEVICE_ID_FILE_NAME, Context.MODE_PRIVATE);
|
||||
|
||||
FileInputStream fis = openFileInput(Util.DEVICE_ID_FILE_NAME);
|
||||
|
||||
byte[] blah = new byte[fis.available()];
|
||||
|
||||
int bytesRead = fis.read(blah, 0, fis.available());
|
||||
|
||||
String test = new String(blah, "UTF-8");
|
||||
|
||||
Log.i("TEST", test);
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
mChatCodeView = (EditText) findViewById(R.id.token);
|
||||
mTenantView = (EditText) findViewById(R.id.tenant);
|
||||
mUsernameView = (EditText) findViewById(R.id.username);
|
||||
@@ -136,20 +153,17 @@ public class LoginActivity extends ActionBarActivity {
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
|
||||
super.onStart();
|
||||
spiceManager.start(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
|
||||
spiceManager.shouldStop();
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
private void attemptLogin() {
|
||||
|
||||
mTenantView.setError(null);
|
||||
mChatCodeView.setError(null);
|
||||
mUsernameView.setError(null);
|
||||
@@ -262,10 +276,6 @@ public class LoginActivity extends ActionBarActivity {
|
||||
return;
|
||||
}
|
||||
|
||||
Gson gson = new GsonBuilder().create();
|
||||
|
||||
//boolean loginResult = Boolean.valueOf(soapPrimitive.toString());
|
||||
//Employee loggedInUser = gson.fromJson(soapPrimitive.toString(), Employee.class);
|
||||
String abc = soapPrimitive.toString();
|
||||
|
||||
if(abc != null) {
|
||||
@@ -299,6 +309,11 @@ public class LoginActivity extends ActionBarActivity {
|
||||
}
|
||||
}
|
||||
|
||||
SocketManager.tenant = mTenantView.getText().toString();
|
||||
|
||||
SocketManager.connectToServer();
|
||||
SocketManager.LoginOnServer();
|
||||
|
||||
Intent mainActivityMitarbeiter = new Intent(LoginActivity.this, MainActivityMitarbeiter.class);
|
||||
LoginActivity.this.startActivity(mainActivityMitarbeiter);
|
||||
}
|
||||
@@ -310,7 +325,6 @@ public class LoginActivity extends ActionBarActivity {
|
||||
}
|
||||
|
||||
private void showLoginUIErrors(boolean token, boolean tenant, boolean username, boolean password) {
|
||||
|
||||
mChatCodeView.setError(token ? getString(R.string.error_invalid_input) : null);
|
||||
|
||||
mTenantView.setError(tenant ? getString(R.string.error_invalid_input) : null);
|
||||
@@ -321,7 +335,6 @@ public class LoginActivity extends ActionBarActivity {
|
||||
}
|
||||
|
||||
private void clearSharedPreferences() {
|
||||
|
||||
SharedPreferences settings = getSharedPreferences(Util.PREFS_NAME, 0);
|
||||
settings.edit().clear().commit();
|
||||
}
|
||||
|
||||
@@ -5,35 +5,24 @@ import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Color;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.os.Bundle;
|
||||
import android.util.Base64;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.Socket;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import soapConnection.DataIdentifier;
|
||||
import soapConnection.Packet;
|
||||
import soapConnection.SoapCalls;
|
||||
import soapConnection.SoapConnectionManager;
|
||||
|
||||
import util.SecurityUtils;
|
||||
import util.Util;
|
||||
import tcpConnection.SocketManager;
|
||||
import tcpConnection.UIHandler;
|
||||
|
||||
|
||||
public class MainActivityMitarbeiter extends Activity {
|
||||
@@ -42,19 +31,15 @@ public class MainActivityMitarbeiter extends Activity {
|
||||
protected Button chatbutton;
|
||||
protected Button logoutbutton;
|
||||
|
||||
public static Socket socket;
|
||||
DataOutputStream dataOutputStream;
|
||||
|
||||
//Name, der Zum Server gesendet wird
|
||||
protected String loggedInUserName;
|
||||
|
||||
public static Thread listen;
|
||||
public static SocketListener socketListener;
|
||||
private UIHandler mainUIHandler;
|
||||
|
||||
int loggedInUserPersonOid;
|
||||
|
||||
private ArrayList<Integer> onlinePersonOids;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -68,7 +53,24 @@ public class MainActivityMitarbeiter extends Activity {
|
||||
|
||||
onlinePersonOids = new ArrayList<>();
|
||||
|
||||
StartServerConnection();
|
||||
mainUIHandler = new UIHandler() {
|
||||
@Override
|
||||
public void updateUserInterface(Packet chatPacket) {
|
||||
if(chatPacket.ChatDataIdentifier.equals(DataIdentifier.MESSAGE)) {
|
||||
Log.i("MAIN_ACTIVIY_LISTENER", "Empfange Nachricht... <<" + chatPacket.ChatMessage + ">>");
|
||||
chatPacket.writeToLog();
|
||||
SetNotify(chatPacket.ChatName, chatPacket.ChatMessage, chatPacket.SenderPersonOid);
|
||||
} else if(chatPacket.ChatDataIdentifier.equals(DataIdentifier.STATUS_NOTIFICATION_LOGIN_BROADCAST)) {
|
||||
|
||||
String[] bitch = chatPacket.ChatMessage.split(",");
|
||||
onlinePersonOids = new ArrayList<>();
|
||||
|
||||
for (String aBitch : bitch) {
|
||||
onlinePersonOids.add(Integer.parseInt(aBitch));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -109,11 +111,11 @@ public class MainActivityMitarbeiter extends Activity {
|
||||
chatbutton.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
|
||||
if(socket == null || !socket.isConnected()) {
|
||||
Toast.makeText(getApplicationContext(), "Der Chatserver ist zurzeit nicht erreichbar. \nBitte versuchen Sie es später erneut.", Toast.LENGTH_LONG).show();
|
||||
|
||||
return;
|
||||
}
|
||||
// if(socket == null || !socket.isConnected()) {
|
||||
// Toast.makeText(getApplicationContext(), "Der Chatserver ist zurzeit nicht erreichbar. \nBitte versuchen Sie es später erneut.", Toast.LENGTH_LONG).show();
|
||||
//
|
||||
// return;
|
||||
// }
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
|
||||
@@ -131,17 +133,19 @@ public class MainActivityMitarbeiter extends Activity {
|
||||
logoutbutton.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
|
||||
if(socket != null && socket.isConnected()) {
|
||||
try {
|
||||
Packet p = new Packet();
|
||||
// if(socket != null && socket.isConnected()) {
|
||||
// try {
|
||||
// Packet p = new Packet();
|
||||
//
|
||||
// p.ChatDataIdentifier = DataIdentifier.LOGOUT;
|
||||
//
|
||||
// new Thread(new MessageSender(p.getDataStream())).start();
|
||||
// } catch(Exception e) {
|
||||
// Log.e("SendAfterGetConnection", "Fehler beim Logout: " + e.getMessage());
|
||||
// }
|
||||
// }
|
||||
|
||||
p.ChatDataIdentifier = DataIdentifier.LOGOUT;
|
||||
|
||||
new Thread(new MessageSender(p.GetDataStream())).start();
|
||||
} catch(Exception e) {
|
||||
Log.e("SendAfterGetConnection", "Fehler beim Logout: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
SocketManager.Logout();
|
||||
|
||||
finish();
|
||||
System.exit(0);
|
||||
@@ -149,180 +153,6 @@ public class MainActivityMitarbeiter extends Activity {
|
||||
});
|
||||
}
|
||||
|
||||
public void StartServerConnection(){
|
||||
|
||||
new Thread(new OpenConnection()).start();
|
||||
}
|
||||
|
||||
public class OpenConnection implements Runnable{
|
||||
public void run(){
|
||||
try {
|
||||
socket = new Socket(SoapCalls.DESTINATION_ADDRESS, SoapCalls.DESTINATION_PORT);
|
||||
|
||||
SendAfterGetConnection();
|
||||
|
||||
dataOutputStream = new DataOutputStream(socket.getOutputStream());
|
||||
|
||||
socketListener = new SocketListener();
|
||||
listen = new Thread(socketListener);
|
||||
listen.start();
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.e("Connection: ","Konnte nicht aufgebaut werden. Es wird erneut versucht. Nachricht: " + e.getMessage());
|
||||
|
||||
socket = null;
|
||||
try {
|
||||
new Timer().schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
Log.i("Status", "Starte jetzt den Neu versuch");
|
||||
StartServerConnection();
|
||||
}
|
||||
}, 120000); //----> Versuche beim Scheitern nach 2 Minuten eine Neue Verbindung aufzubauen
|
||||
}catch(Exception s){
|
||||
Log.e("Fehler", s.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void CloseMainActivitySocketListener() {
|
||||
if(listen != null && listen.isAlive()) {
|
||||
try {
|
||||
socketListener.terminate();
|
||||
listen.join();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class SocketListener implements Runnable {
|
||||
|
||||
Packet chatPacket;
|
||||
|
||||
private volatile boolean running = true;
|
||||
|
||||
public void terminate() {
|
||||
running = false;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
while (running) {
|
||||
if (socket != null) {
|
||||
if (socket.isConnected()) {
|
||||
|
||||
InputStream stream = socket.getInputStream();
|
||||
|
||||
int size = stream.available();
|
||||
|
||||
if(size == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
StringBuilder total = new StringBuilder(stream.available());
|
||||
|
||||
int counter = 0;
|
||||
|
||||
while(counter < size) {
|
||||
|
||||
char c = (char) stream.read();
|
||||
|
||||
total.append(c);
|
||||
|
||||
counter++;
|
||||
}
|
||||
|
||||
chatPacket = new Packet(total.toString());
|
||||
|
||||
if(chatPacket.ChatDataIdentifier.equals(DataIdentifier.MESSAGE)) {
|
||||
SetNotify(chatPacket.ChatName, chatPacket.ChatMessage, chatPacket.RecipientPersonOid);
|
||||
} else if(chatPacket.ChatDataIdentifier.equals(DataIdentifier.STATUS_NOTIFICATION_LOGIN_BROADCAST)) {
|
||||
|
||||
String[] bitch = chatPacket.ChatMessage.split(",");
|
||||
onlinePersonOids = new ArrayList<>();
|
||||
|
||||
for (String aBitch : bitch) {
|
||||
onlinePersonOids.add(Integer.parseInt(aBitch));
|
||||
}
|
||||
}
|
||||
|
||||
Log.i("MAIN_ACTIVITY", "Erhaltene Nachricht: " + chatPacket.ChatMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch(Exception e) {
|
||||
Log.e("Listener/Main", "" + e);
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ConnectionClose implements Runnable{
|
||||
public void run(){
|
||||
try {
|
||||
if (dataOutputStream != null) {
|
||||
dataOutputStream.flush();
|
||||
dataOutputStream.close();
|
||||
}
|
||||
|
||||
if (socket != null) {
|
||||
socket.close();
|
||||
}
|
||||
|
||||
Log.i("MAIN CONNECTION CLOSE","Socket succesfully closed");
|
||||
}catch(IOException se){
|
||||
Log.e("MAIN ERROR:", se.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SendAfterGetConnection(){
|
||||
|
||||
if(socket.isConnected()) {
|
||||
try {
|
||||
Packet p = new Packet();
|
||||
|
||||
SharedPreferences settings = getSharedPreferences(Util.PREFS_NAME, 0);
|
||||
|
||||
byte[] tenantByteArray = Base64.decode(settings.getString(Util.PREFS_TENANT_KEY, null), Base64.DEFAULT);
|
||||
ByteArrayInputStream tenantStream = new ByteArrayInputStream(tenantByteArray);
|
||||
|
||||
p.Tenant = SecurityUtils.decrypt(tenantStream).toString();
|
||||
p.ChatDataIdentifier = DataIdentifier.LOGIN;
|
||||
|
||||
new Thread(new MessageSender(p.GetDataStream())).start();
|
||||
} catch(Exception e) {
|
||||
Log.e("SendAfterGetConnection", "Fehler beim Senden einer Nachricht an den Server: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class MessageSender implements Runnable {
|
||||
|
||||
byte[] packetToSend;
|
||||
|
||||
public MessageSender(byte[] packet2Send) {
|
||||
packetToSend = packet2Send;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if(socket != null && dataOutputStream != null) {
|
||||
|
||||
dataOutputStream.write(packetToSend);
|
||||
dataOutputStream.flush();
|
||||
}
|
||||
} catch(Exception e) {
|
||||
Log.e("MessageSender", "Fehler beim Senden der TestMessage " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetNotify(String username, String message, int recipientOid){
|
||||
|
||||
//Convertiert in Pic Resource in ein Bitmap
|
||||
@@ -360,20 +190,8 @@ public class MainActivityMitarbeiter extends Activity {
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
SocketManager.uiHandler = mainUIHandler;
|
||||
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop(){
|
||||
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
public void onDestroy(){
|
||||
Thread t = new Thread(new ConnectionClose());
|
||||
t.start();
|
||||
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,8 +41,6 @@ public class MessageAdapter extends ArrayAdapter<ChatMessage> {
|
||||
|
||||
if (chatMessage.SenderPersonOid == SoapConnectionManager.User.getPersonOid()) {
|
||||
layoutResource = R.layout.item_chat_right;
|
||||
// } else if(splitt[0].equals("Server")) {
|
||||
// layoutResource = R.layout.item_chat_sever_right;
|
||||
}else {
|
||||
layoutResource = R.layout.item_chat_left;
|
||||
}
|
||||
@@ -53,12 +51,6 @@ public class MessageAdapter extends ArrayAdapter<ChatMessage> {
|
||||
|
||||
holder.msg.setText(chatMessage.ChatText);
|
||||
|
||||
//TODO eine weitere option für Chatmessage hinzufügen zum abfragen wegen send Message
|
||||
|
||||
if(holder.send_tick != null) {
|
||||
holder.send_tick.setText(Html.fromHtml("✓") + "" + Html.fromHtml("✓"));
|
||||
}
|
||||
|
||||
if(chatMessage.SenderPersonOid == SoapConnectionManager.User.getPersonOid()){
|
||||
holder.dateIn.setText(chatMessage.getInsTsAsString());
|
||||
} else {
|
||||
|
||||
@@ -12,7 +12,9 @@ public enum DataIdentifier {
|
||||
STATUS_NOTIFICATION_LOGOUT(5),
|
||||
OLD_MESSAGE(6),
|
||||
DELIVERING_STATUS_CHANGE(7),
|
||||
STATUS_NOTIFICATION_LOGIN_BROADCAST(8);
|
||||
STATUS_NOTIFICATION_LOGIN_BROADCAST(8),
|
||||
TEAM(9),
|
||||
MESSAGE_RESPONSE(10);
|
||||
|
||||
private final int value;
|
||||
DataIdentifier(int value) {
|
||||
|
||||
@@ -51,6 +51,8 @@ public class Packet {
|
||||
|
||||
public Packet(String message) {
|
||||
|
||||
Log.d("PACKET >>>>>>>>>", message);
|
||||
|
||||
String[] gesplittet = message.split(";");
|
||||
|
||||
String senderPersonOidString = gesplittet[0];
|
||||
@@ -91,9 +93,9 @@ public class Packet {
|
||||
IsDelivered = Integer.parseInt(actualMessage.substring(chatMessageLength + chatNameLength + 19, chatMessageLength + chatNameLength + 20)) != 0;
|
||||
}
|
||||
|
||||
public byte[] GetDataStream() {
|
||||
public byte[] getDataStream() {
|
||||
|
||||
String dataStreamAsString = "" + SenderPersonOid + ";" + RecipientPersonOid + ";" + ChatName.length() + ";" + ChatMessage.length()+ ";" + ChatDataIdentifier.getValue() + ";" + ServerseitigeOid + ";" + Tenant + ";";
|
||||
String dataStreamAsString = "" + SenderPersonOid + ";" + RecipientPersonOid + ";" + ChatName.length() + ";" + ChatMessage.length()+ ";" + ChatDataIdentifier.getValue() + ";" + ServerseitigeOid + ";" + ClientseitigeOid + ";" + Tenant + ";";
|
||||
|
||||
dataStreamAsString += ChatName + ChatMessage + getFormattedMessageTimeStamp() + "" + (IsDelivered ? 1 : 0);
|
||||
|
||||
@@ -102,13 +104,13 @@ public class Packet {
|
||||
try {
|
||||
blaaah = dataStreamAsString.getBytes("UTF8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
Log.e("Packet.GetDataStream", e.getMessage());
|
||||
Log.e("Packet.getDataStream", e.getMessage());
|
||||
}
|
||||
|
||||
return blaaah;
|
||||
}
|
||||
|
||||
public void WriteToLog() {
|
||||
Log.i("PACKET_LOG", "SenderPersonOid: " + SenderPersonOid + "\nRecipientPersonOid: " + RecipientPersonOid + "\nChatDataIdentifier: " + ChatDataIdentifier.name() + "\nChatName: " + ChatName + "\nChatMessage: " + ChatMessage + "\nTenant: " + Tenant + "\nIsDelivered: " + IsDelivered + "\nMessageTimeStamp: " + MessageTimeStamp + "\nServerseitigeOid: " + ServerseitigeOid);
|
||||
public void writeToLog() {
|
||||
Log.i("PACKET_LOG", "SenderPersonOid: " + SenderPersonOid + "\nRecipientPersonOid: " + RecipientPersonOid + "\nChatDataIdentifier: " + ChatDataIdentifier.name() + "\nChatName: " + ChatName + "\nChatMessage: " + ChatMessage + "\nTenant: " + Tenant + "\nIsDelivered: " + IsDelivered + "\nMessageTimeStamp: " + MessageTimeStamp + "\nServerseitigeOid: " + ServerseitigeOid + "\nClientseitigeOid: " + ClientseitigeOid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ public class SoapCalls {
|
||||
|
||||
public static String TOKEN_CHECK_URL = "http://" + DESTINATION_ADDRESS + "/bewoplanermobil/main/checktoken?token=";
|
||||
|
||||
public static String WEB_DOKU_URL = "http://192.168.1.103/BewoPlanerMobil/login/demo";
|
||||
public static String WEB_DOKU_URL = "http://" + DESTINATION_ADDRESS + "/BewoPlanerMobil/login/demo";
|
||||
|
||||
public static String WSDL_TARGET_NAME = "bliblablubb.org/";
|
||||
public static String SOAP_ADDRESS = "http://" + DESTINATION_ADDRESS + "/BeWoPlanerAndroid/AndroidSoapService.asmx";
|
||||
|
||||
@@ -0,0 +1,217 @@
|
||||
package tcpConnection;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.Socket;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import soapConnection.DataIdentifier;
|
||||
import soapConnection.Packet;
|
||||
import soapConnection.SoapCalls;
|
||||
|
||||
/**
|
||||
* Created by JettenM on 04.08.2016.
|
||||
*/
|
||||
public class SocketManager {
|
||||
|
||||
private static final String TAG = "SOCKET_MANAGER";
|
||||
|
||||
public static String tenant;
|
||||
public static Socket socket;
|
||||
public static Thread listenerThread;
|
||||
public static SocketListener socketListener;
|
||||
public static UIHandler uiHandler;
|
||||
public static DataOutputStream dataOutputStream;
|
||||
|
||||
public static void connectToServer(){
|
||||
new Thread(new OpenConnection()).start();
|
||||
}
|
||||
|
||||
public static void sendMessage(Packet packet) {
|
||||
new Thread(new MessageSender(packet.getDataStream())).start();
|
||||
}
|
||||
|
||||
public static class OpenConnection implements Runnable {
|
||||
public void run() {
|
||||
try {
|
||||
socket = new Socket(SoapCalls.DESTINATION_ADDRESS, SoapCalls.DESTINATION_PORT);
|
||||
|
||||
LoginOnServer();
|
||||
|
||||
dataOutputStream = new DataOutputStream(socket.getOutputStream());
|
||||
|
||||
socketListener = new SocketListener();
|
||||
listenerThread = new Thread(socketListener);
|
||||
listenerThread.start();
|
||||
} catch(Exception exception) {
|
||||
socket = null;
|
||||
try {
|
||||
new Timer().schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
connectToServer();
|
||||
}
|
||||
}, 30000);
|
||||
} catch(Exception exception2) {
|
||||
exception2.printStackTrace();
|
||||
}
|
||||
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void closeSocketListener() {
|
||||
if(listenerThread != null && listenerThread.isAlive()) {
|
||||
try {
|
||||
socketListener.terminate();
|
||||
listenerThread.join();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Logout() {
|
||||
if(socket != null && socket.isConnected()) {
|
||||
try {
|
||||
Packet packet = new Packet();
|
||||
|
||||
packet.ChatDataIdentifier = DataIdentifier.LOGOUT;
|
||||
|
||||
new Thread(new MessageSender(packet.getDataStream())).start();
|
||||
|
||||
} catch(Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void LoginOnServer() {
|
||||
if(socket != null && socket.isConnected()) {
|
||||
try {
|
||||
Packet packet = new Packet();
|
||||
packet.Tenant = tenant;
|
||||
|
||||
packet.ChatDataIdentifier = DataIdentifier.LOGIN;
|
||||
|
||||
new Thread(new MessageSender(packet.getDataStream())).start();
|
||||
|
||||
} catch(Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ConnectionClose implements Runnable{
|
||||
public void run(){
|
||||
try {
|
||||
if (dataOutputStream != null) {
|
||||
dataOutputStream.flush();
|
||||
dataOutputStream.close();
|
||||
}
|
||||
|
||||
if (socket != null) {
|
||||
socket.close();
|
||||
}
|
||||
|
||||
}catch(IOException se){
|
||||
se.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class MessageSender implements Runnable {
|
||||
byte[] packetToSend;
|
||||
|
||||
public MessageSender(byte[] packet2Send) {
|
||||
packetToSend = packet2Send;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if(!socket.isConnected()) {
|
||||
Log.e("MESSAGE_SENDER", "Socket ist nicht verbunden");
|
||||
}
|
||||
|
||||
if(socket != null && dataOutputStream != null) {
|
||||
try {
|
||||
dataOutputStream.write(packetToSend);
|
||||
dataOutputStream.flush();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class SocketListener implements Runnable {
|
||||
|
||||
Packet chatPacket;
|
||||
|
||||
private volatile boolean isRunning = true;
|
||||
|
||||
public void terminate() {
|
||||
isRunning = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
while (isRunning) {
|
||||
if (socket != null) {
|
||||
if (socket.isConnected()) {
|
||||
|
||||
InputStream stream = socket.getInputStream();
|
||||
|
||||
int size = stream.available();
|
||||
|
||||
if(size == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
StringBuilder total = new StringBuilder(stream.available());
|
||||
|
||||
int counter = 0;
|
||||
|
||||
byte[] message = new byte[size];
|
||||
|
||||
stream.read(message, 0, size);
|
||||
|
||||
// while(counter < size) {
|
||||
//
|
||||
// char c = (char) stream.read();
|
||||
//
|
||||
// total.append(c);
|
||||
//
|
||||
// counter++;
|
||||
// }
|
||||
|
||||
try {
|
||||
//chatPacket = new Packet(total.toString());
|
||||
chatPacket = new Packet(new String(message, "UTF-8"));
|
||||
|
||||
Log.i(TAG, "Empfange Nachricht... " + chatPacket.ChatMessage);
|
||||
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if(uiHandler != null) {
|
||||
uiHandler.updateUserInterface(chatPacket);
|
||||
} else {
|
||||
Log.e("ERROR_SOCKETLISTENER", "uiHandler ist null");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch(Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package tcpConnection;
|
||||
|
||||
import soapConnection.Packet;
|
||||
|
||||
/**
|
||||
* Created by JettenM on 04.08.2016.
|
||||
*/
|
||||
public interface UIHandler {
|
||||
void updateUserInterface(Packet chatPacket);
|
||||
}
|
||||
@@ -8,8 +8,11 @@ public class Util {
|
||||
|
||||
public static final String PREFS_SERVERADDRESS_KEY = "serverAddress";
|
||||
|
||||
public static final String PREFS_TOKEN_KEY = "serverAddress";
|
||||
public static final String PREFS_TENANT_KEY = "tenant";
|
||||
public static final String PREFS_TOKEN_KEY = "serverAddress";
|
||||
public static final String PREFS_TENANT_KEY = "tenant";
|
||||
public static final String PREFS_USERNAME_KEY = "username";
|
||||
public static final String PREFS_PASSWORD = "password";
|
||||
public static final String PREFS_PASSWORD = "password";
|
||||
|
||||
public static final String DEVICE_ID_FILE_NAME = "bewodeviceidfile";
|
||||
public static final String DEVICE_ID = "";
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
android:layout_marginBottom="@dimen/activity_horizontal_margin"
|
||||
android:divider="@null"
|
||||
android:listSelector="@android:color/transparent"
|
||||
android:stackFromBottom="true"
|
||||
android:transcriptMode="alwaysScroll" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -15,13 +15,13 @@
|
||||
NHibernate.Driver.MySqlDataDriver
|
||||
</property>
|
||||
|
||||
<property name="connection.connection_string">
|
||||
<!-- <property name="connection.connection_string">
|
||||
Server=localhost;Password=root;User ID=root;Initial Catalog=bewodemo
|
||||
</property>
|
||||
</property>-->
|
||||
|
||||
<!--<property name="connection.connection_string">
|
||||
<property name="connection.connection_string">
|
||||
Server=localhost;Password=root;User ID=root;Initial Catalog=1234567890
|
||||
</property>-->
|
||||
</property>
|
||||
|
||||
<property name="dialect">
|
||||
NHibernate.Dialect.MySQLDialect
|
||||
|
||||
@@ -131,7 +131,7 @@ namespace BeWoChatServer
|
||||
}
|
||||
|
||||
// Boradcast
|
||||
var abc = clientList.Select(s => s.Value).Distinct().ToList();
|
||||
var abc = clientList.Where(w => w.Value != dataPacket.SenderPersonOid).Select(s => s.Value).Distinct().ToList();
|
||||
var msg = "";
|
||||
|
||||
foreach(var oid in abc)
|
||||
@@ -144,9 +144,12 @@ namespace BeWoChatServer
|
||||
}
|
||||
}
|
||||
|
||||
var packet = new Packet {ChatMessage = msg, ClientName = dataPacket.ClientName, DataIdentifier = DataIdentifier.StatusNotificationLoginBroadcast, MessageTimeStamp = DateTime.Now, Tenant = dataPacket.Tenant, SenderPersonOid = dataPacket.SenderPersonOid};
|
||||
if(msg.Length > 0)
|
||||
{
|
||||
var packet = new Packet {ChatMessage = msg, ClientName = dataPacket.ClientName, DataIdentifier = DataIdentifier.StatusNotificationLoginBroadcast, MessageTimeStamp = DateTime.Now, Tenant = dataPacket.Tenant, SenderPersonOid = dataPacket.SenderPersonOid};
|
||||
|
||||
dataPacket.Socket.Send(packet.GetDataStream());
|
||||
dataPacket.Socket.Send(packet.GetDataStream());
|
||||
}
|
||||
|
||||
break;
|
||||
case DataIdentifier.Message:
|
||||
@@ -198,6 +201,10 @@ namespace BeWoChatServer
|
||||
{
|
||||
recipient.Key.Send(dataPacket.GetDataStream());
|
||||
}
|
||||
|
||||
var packet = new Packet {ClientseitigeOid = dataPacket.ClientseitigeOid, ServerseitigeOid = dataPacket.ServerseitigeOid, DataIdentifier = DataIdentifier.MessageResponse};
|
||||
|
||||
dataPacket.Socket.Send(packet.GetDataStream());
|
||||
}
|
||||
}
|
||||
finally
|
||||
|
||||
Binary file not shown.
@@ -123,7 +123,7 @@
|
||||
<add key="PreserveLoginUrl" value="true" />
|
||||
<add key="ClientValidationEnabled" value="true" />
|
||||
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
|
||||
<add key="MultitenancyPath" value="F:\Projects\BeWo\Host\Multitenancy\" />
|
||||
<add key="MultitenancyPath" value="C:\Projekte\BeWo\Host\Multitenancy\" />
|
||||
<!--<add key="MultitenancyPath" value="..\Host\Multitenancy"/>-->
|
||||
</appSettings>
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -15,13 +15,13 @@
|
||||
NHibernate.Driver.MySqlDataDriver
|
||||
</property>
|
||||
|
||||
<property name="connection.connection_string">
|
||||
<!-- <property name="connection.connection_string">
|
||||
Server=localhost;Password=root;User ID=root;Initial Catalog=bewodemo
|
||||
</property>
|
||||
</property>-->
|
||||
|
||||
<!--<property name="connection.connection_string">
|
||||
<property name="connection.connection_string">
|
||||
Server=localhost;Password=root;User ID=root;Initial Catalog=1234567890
|
||||
</property>-->
|
||||
</property>
|
||||
|
||||
<property name="dialect">
|
||||
NHibernate.Dialect.MySQLDialect
|
||||
|
||||
@@ -833,6 +833,7 @@ namespace BS.Shared
|
||||
OldMessage,
|
||||
DeliveringStatusChange,
|
||||
StatusNotificationLoginBroadcast,
|
||||
Team
|
||||
Team,
|
||||
MessageResponse
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user