Packet: ClientseitigeOid (Id in der SQLite Datenbank) hinzugefügt, um die Nachricht in der App zuordnen zu können.
This commit is contained in:
@@ -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" />
|
||||
|
||||
@@ -26,18 +26,22 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
||||
//DataBase version
|
||||
private static final int DATABASE_VERSION = 1;
|
||||
//Database name
|
||||
private static final String DATABASE_NAME = "Contacts_Manager";
|
||||
private static final String DATABASE_NAME = "Contacts_Manager";
|
||||
//Table Name
|
||||
private static final String TABLE_CONTACTS = "Contactlist";
|
||||
private static final String TABLE_CHATMESSAGE = "ChatMessage";
|
||||
|
||||
|
||||
//Table Columns name
|
||||
|
||||
// Contacts-Tabelle
|
||||
private static final String KEY_ID ="id";
|
||||
private static final String KEY_KontaktName = "kontaktname";
|
||||
private static final String KEY_PERSONOID = "personoid";
|
||||
private static final String KEY_Picture_BLOB = "bild";
|
||||
|
||||
|
||||
// ChatMessage-Tabelle
|
||||
private static final String KEY_ID_CHATMESSAGE = "id";
|
||||
private static final String KEY_SENDER_PERSON_OID_CHATMESSAGE = "senderpersonoid";
|
||||
private static final String KEY_RECIPIENT_PERSON_OID_CHATMESSAGE = "recipientpersonoid";
|
||||
@@ -84,7 +88,8 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
||||
values.put(KEY_IS_DELIVERED_CHATMESSAGE, (message.IsDelivered ? 1 : 0));
|
||||
values.put(KEY_SERVERSEITIGE_OID_CHATMESSAGE, message.ServerseitigeOid);
|
||||
|
||||
db.insert(TABLE_CHATMESSAGE, null, values);
|
||||
long rowId = db.insert(TABLE_CHATMESSAGE, null, values);
|
||||
Log.i("CHAT_MESSAGE_INSERT", "RowID: " + rowId);
|
||||
db.close();
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ public class KontaktChatActivity extends ListActivity {
|
||||
|
||||
databaseHandler = new DatabaseHandler(this);
|
||||
|
||||
//TODO: nicht löschen, sondern updaten
|
||||
//TODO: nicht löschen, sondern updaten...
|
||||
//databaseHandler.onUpgrade(databaseHandler.getReadableDatabase(), 1, 2);
|
||||
|
||||
Bundle bundle = getIntent().getExtras();
|
||||
@@ -99,14 +99,15 @@ public class KontaktChatActivity extends ListActivity {
|
||||
in.putExtras(bundle);
|
||||
|
||||
//Gib Bild für den Chat mit
|
||||
if(selectedValue.getPicture() == null){
|
||||
if(selectedValue.getPicture() == null) {
|
||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||
Bitmap a = BitmapFactory.decodeResource(getResources(), R.drawable.katze3);
|
||||
a.compress(Bitmap.CompressFormat.JPEG,0,stream);
|
||||
byte[] x = stream.toByteArray();
|
||||
in.putExtra("Bild", x);
|
||||
}else
|
||||
} else {
|
||||
in.putExtra("Bild", selectedValue.getPicture());
|
||||
}
|
||||
|
||||
startActivity(in);
|
||||
}
|
||||
@@ -137,6 +138,8 @@ 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();
|
||||
|
||||
@@ -18,8 +18,6 @@ import android.widget.Button;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.Socket;
|
||||
@@ -49,9 +47,6 @@ public class MainActivityMitarbeiter extends Activity {
|
||||
//Name, der Zum Server gesendet wird
|
||||
protected String loggedInUserName;
|
||||
|
||||
File file;
|
||||
File unsentFile;
|
||||
|
||||
public static Thread listen;
|
||||
public static SocketListener socketListener;
|
||||
|
||||
@@ -96,7 +91,6 @@ public class MainActivityMitarbeiter extends Activity {
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
|
||||
public void setzeButtonListener() {
|
||||
|
||||
dokubutton = (Button) findViewById(R.id.Dokubutton);
|
||||
@@ -355,11 +349,13 @@ public class MainActivityMitarbeiter extends Activity {
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop(){
|
||||
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
|
||||
@@ -24,8 +24,7 @@ public class Packet {
|
||||
public String Tenant;
|
||||
public boolean IsDelivered;
|
||||
public int ServerseitigeOid;
|
||||
|
||||
// TODO: IsDelivered einbauen
|
||||
public int ClientseitigeOid;
|
||||
|
||||
public Packet() {
|
||||
ChatDataIdentifier = DataIdentifier.NULL;
|
||||
@@ -46,9 +45,9 @@ public class Packet {
|
||||
|
||||
//Aufbau Message:
|
||||
// die ersten fünf ";" ignorieren
|
||||
// SenderOid;RecipientOid;ClientNameLength;MessageLength;ChatDataIdentifier;ServerseitigeOid;Tenant;[ClientName][ChatMessage][MessageTimeStamp][IsDelivered]
|
||||
// SenderOid;RecipientOid;ClientNameLength;MessageLength;ChatDataIdentifier;ServerseitigeOid;ClientseitigeOid;Tenant;[ClientName][ChatMessage][MessageTimeStamp][IsDelivered]
|
||||
|
||||
//23;281;20;389;1;38;[Tenant]; 7 Semikola
|
||||
//23;281;20;389;1;38;932[Tenant]; 8 Semikola
|
||||
|
||||
public Packet(String message) {
|
||||
|
||||
@@ -60,18 +59,20 @@ public class Packet {
|
||||
String chatMessageLengthString = gesplittet[3];
|
||||
String chatIdentifierString = gesplittet[4];
|
||||
String serverseitigeOidString = gesplittet[5];
|
||||
Tenant = gesplittet[6];
|
||||
String clientseitigeOidString = gesplittet[6];
|
||||
Tenant = gesplittet[7];
|
||||
|
||||
SenderPersonOid = Integer.parseInt(senderPersonOidString);
|
||||
RecipientPersonOid = Integer.parseInt(recipientPersonOidString);
|
||||
ServerseitigeOid = Integer.parseInt(serverseitigeOidString);
|
||||
ServerseitigeOid = Integer.parseInt(serverseitigeOidString);
|
||||
ClientseitigeOid = Integer.parseInt(clientseitigeOidString);
|
||||
|
||||
ChatDataIdentifier = DataIdentifier.getEnumValue(Integer.parseInt(chatIdentifierString));
|
||||
|
||||
int chatNameLength = Integer.parseInt(chatNameLengthString);
|
||||
int chatMessageLength = Integer.parseInt(chatMessageLengthString);
|
||||
|
||||
int headerLength = senderPersonOidString.length() + recipientPersonOidString.length() + chatNameLengthString.length() + chatMessageLengthString.length() + chatIdentifierString.length() + Tenant.length() + serverseitigeOidString.length() + 8;
|
||||
int headerLength = senderPersonOidString.length() + recipientPersonOidString.length() + chatNameLengthString.length() + chatMessageLengthString.length() + chatIdentifierString.length() + Tenant.length() + serverseitigeOidString.length() + clientseitigeOidString.length() + 9;
|
||||
String actualMessage = message.substring(headerLength - 1);
|
||||
|
||||
ChatName = actualMessage.substring(0, chatNameLength);
|
||||
|
||||
Binary file not shown.
File diff suppressed because one or more lines are too long
@@ -1,40 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<configuration>
|
||||
|
||||
<configSections>
|
||||
<section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
|
||||
</configSections>
|
||||
|
||||
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
|
||||
<session-factory>
|
||||
<property name="connection.provider">
|
||||
NHibernate.Connection.DriverConnectionProvider
|
||||
</property>
|
||||
<property name="connection.driver_class">
|
||||
NHibernate.Driver.MySqlDataDriver
|
||||
</property>
|
||||
|
||||
<property name="connection.connection_string">
|
||||
Server=localhost;Password=root;User ID=root;Initial Catalog=bewodemo
|
||||
</property>
|
||||
|
||||
<!--<property name="connection.connection_string">
|
||||
Server=localhost;Password=root;User ID=root;Initial Catalog=1234567890
|
||||
</property>-->
|
||||
|
||||
<property name="dialect">
|
||||
NHibernate.Dialect.MySQLDialect
|
||||
</property>
|
||||
<property name="proxyfactory.factory_class">
|
||||
NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle
|
||||
</property>
|
||||
<property name="hbm2ddl.keywords">none</property>
|
||||
<property name="show_sql">true</property>
|
||||
<property name="format_sql">true</property>
|
||||
|
||||
<mapping assembly="BeWo.Data" />
|
||||
</session-factory>
|
||||
</hibernate-configuration>
|
||||
|
||||
</configuration>
|
||||
@@ -19,6 +19,7 @@ namespace BS.Shared
|
||||
public string Tenant { get; set; }
|
||||
public bool IsDelivered { get; set; }
|
||||
public long ServerseitigeOid { get; set; }
|
||||
public long ClientseitigeOid { get; set; }
|
||||
|
||||
public byte[] DataBuffer = new byte[1024];
|
||||
|
||||
@@ -55,21 +56,22 @@ namespace BS.Shared
|
||||
var chatMessageLengthString = gesplittet[3];
|
||||
var chatIdentifierString = gesplittet[4];
|
||||
var serverseitigeOidString = gesplittet[5];
|
||||
Tenant = gesplittet[6];
|
||||
var clientseitigeOidString = gesplittet[6];
|
||||
Tenant = gesplittet[7];
|
||||
|
||||
DataIdentifier = (DataIdentifier) Convert.ToInt32(chatIdentifierString);
|
||||
|
||||
SenderPersonOid = Convert.ToInt64(senderPersonOidString);
|
||||
SenderPersonOid = Convert.ToInt64(senderPersonOidString);
|
||||
RecipientPersonOid = Convert.ToInt64(recipientPersonOidString);
|
||||
ServerseitigeOid = Convert.ToInt64(serverseitigeOidString);
|
||||
ServerseitigeOid = Convert.ToInt64(serverseitigeOidString);
|
||||
|
||||
var chatNameLength = Convert.ToInt32(chatNameLengthString);
|
||||
var chatNameLength = Convert.ToInt32(chatNameLengthString);
|
||||
var chatMessageLength = Convert.ToInt32(chatMessageLengthString);
|
||||
|
||||
var headerLength = senderPersonOidString.Length + recipientPersonOidString.Length + chatNameLengthString.Length + chatMessageLengthString.Length + chatIdentifierString.Length + Tenant.Length + serverseitigeOidString.Length + 8;
|
||||
var headerLength = senderPersonOidString.Length + recipientPersonOidString.Length + chatNameLengthString.Length + chatMessageLengthString.Length + chatIdentifierString.Length + Tenant.Length + serverseitigeOidString.Length + clientseitigeOidString.Length + 9;
|
||||
var actualMessage = message.Substring(headerLength - 1);
|
||||
|
||||
ClientName = actualMessage.Substring(0, chatNameLength);
|
||||
ClientName = actualMessage.Substring(0, chatNameLength);
|
||||
ChatMessage = actualMessage.Substring(chatNameLength, chatMessageLength);
|
||||
|
||||
var dateString = actualMessage.Substring(chatMessageLength + chatNameLength, 19);
|
||||
@@ -88,7 +90,7 @@ namespace BS.Shared
|
||||
{
|
||||
var result = "";
|
||||
|
||||
result += SenderPersonOid + ";" + RecipientPersonOid + ";" + ClientName.Length + ";" + ChatMessage.Length + ";" + (int)DataIdentifier + ";" + ServerseitigeOid + ";" + Tenant + ";" + ClientName + ChatMessage + DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss") + "" + (IsDelivered ? 1 : 0);
|
||||
result += SenderPersonOid + ";" + RecipientPersonOid + ";" + ClientName.Length + ";" + ChatMessage.Length + ";" + (int) DataIdentifier + ";" + ServerseitigeOid + ";" + ClientseitigeOid + ";" + Tenant + ";" + ClientName + ChatMessage + DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss") + "" + (IsDelivered ? 1 : 0);
|
||||
|
||||
Debug.WriteLine("Verschicke Paket: " + result);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user