SenSocial: A Middleware for Integrating 
Online Social Networks and Mobile Sensing 
Data Streams 
Abhinav Mehrotra, Veljko Pejovic, Mirco Musolesi 
School of Computer Science 
University of Birmingham
Context-aware Systems 
Physical Context Mobile Sensors 
Emotional Context 
Social Context 
Online Social Networks 
2
Context-aware Systems 
Richer 
Contextual 
Information 
App 1 
Real Time 
Integration 
How to integrate? 
Integration 
App 2 
3
Application Scenarios 
Sensor Data 
Social Links 
Sensor Data 
Notification 
Online Social 
Network 
Internet 
Server 
Notification 
Notice of 
friend’s arrival 
to Paris 
Sensor Data 
4
Application Scenarios 
Facebook’s emotional contagion 
experiment, Kramer et al. (2014) 
EmotionSense, Rachuri et al. 
(2010) 
5 
How these can be improved ?
SenSocial 
Richer 
Contextual 
Information 
6
SenSocial Design 
7
Key Abstractions 
Application 
onDataSensed() 
Subscribe Context Data 
SenSocial 
subscribe() 
8 
Publish-Subscribe 
Interaction Paradigm 
Streams Stream Filters 
Stream Aggregators 
Multicast 
Multicast Streams
Publish-Subscribe 
Interaction Paradigm 
Subscription Types 
- Topic-based (e.g., get user’s 
location). 
- Content-based (e.g., get 
user’s location when the user 
posts about football on his/her 
Facebook wall). 
Application 
onDataSensed() 
Subscribe 
subscribe() 
Context 
Data 
SenSocial 
9
Streams 
Types of Stream 
• Continuous (e.g., get user’s location when the user is not 
moving). 
• Social event-based (e.g., get user’s location when the user 
performs an action on Facebook). 
10
Stream Filters 
Data Streams 
Conditions 
A condition comprises of a modality, a comparison operator, and a 
value. 
Example: get location only when a user is not moving. 
Condition c = new Condition(ModalityType.physical_activity, 
Operator.equals, ModalityValue.still); 
Refined Information 
11
Stream Aggregator 
• It wraps multiple streams received by the server into a single 
aggregated stream. 
• Data from individual streams is multiplexed to the same join stream. 
• It works similarly to a normal stream. 
12
Multicast Stream 
Multicast 
• It creates duplicate streams on multiple clients. 
• Clients are selected based on the OSN connectivity and geographic 
location of the users. 
OSN Connectivity Geographic Location 13
Other Features 
Remote Stream Management 
Streams can be created, modified, or destroyed remotely on the 
mobile clients. 
Privacy Control 
By specifying the allowed data type (context modality) and the level 
of granularity (raw or classified). 
14
Evaluation 
15 
Energy Management
Evaluation 
CPU consumption with varying number streams 
Average battery consumption with varying number of OSN actions 
OSN actions 1 2 3 4 5 6 7 
Charge consumed [μAH] 51.7 97.1 142.5 187.8 233.2 278.5 324.3 
Note: the above OSN actions occurred within 20 minute time period and 
each triggered remote sampling of all five supported sensor modalities. 
16
Prototype Applications 
Facebook Sensor Map ConWeb 
17
Facebook Sensor Map 
18
Facebook Sensor Map: Code Snippet 
/*----------- Create streams----------------*/ 
SenSocialManager manager = SenSocialManager.getSenSocialManager(getApplicationContext()); 
String uid = manager.getUserId(); 
User user = manager.getUser(uid); 
Stream s1 = user.getDevice().getStream(SensorUtils.Sensor_Type_Accelerometer, "classified"); 
Stream s2 = user.getDevice().getStream(SensorUtils.Sensor_Type_Microphone, "classified"); 
Stream s3 = user.getDevice().getStream(SensorUtils.Sensor_Type_Location, "raw"); 
/*----------- Create list of filter condition(s) ----------------*/ 
ArrayList<Condition> conditions = new ArrayList<Condition>(); 
Condition c = new Condition(ModalityType.facebook_activity, Operator.equals, ModalityValue.active); 
conditions.add(c); 
/*----------- Add condition list to the filter -----------*/ 
Filter filter = new Filter(conditions); 
/*----------- Set filter to the streams -----------*/ 
s1 = s1.setFilter(filter); 
s2 = s2.setFilter(filter); 
s3 = s3.setFilter(filter); 
/*----------- Register streams -----------*/ 
manager.registerListener(this, stream1.getId()); 
manager.registerListener(this, stream2.getId()); 
manager.registerListener(this, stream3.getId()); 
/*----------- Start streams -----------*/ 
stream1.start(); 
stream2.start(); 
stream3.start(); 19
Programming Effort Evaluation 
Facebook Sensor Map : lines of code reduced by nine times (from 3423 
to 316). 
ConWeb : lines of code reduced by twenty four times (from 3223 to 130). 
Application Name Number of files Lines of code 
Facebook Sensor Map (M) (with SenSocial) 8 103 
Facebook Sensor Map (S) (with SenSocial) 2 213 
Facebook Sensor Map (M) (without SenSocial) 68 2419 
Facebook Sensor Map (S) (without SenSocial) 42 1004 
ConWeb (M) (with SenSocial) 3 23 
ConWeb (S) (with SenSocial) 1 107 
ConWeb (M) (without SenSocial) 61 2278 
ConWeb (S) (without SenSocial) 38 945 
20
Summary 
• We argue that the integration of OSNs and mobile sensor data 
streams can benefit in obtaining richer contextual information. 
• We propose SenSocial to simplify the implementation of such 
ubiquitous computing applications. 
• SenSocial is released as an open-source project. 
Available at: https://github.com/AbhinavMehrotra/SenSocial-Library 
21
http://www.cs.bham.ac.uk/~axm514/sensocial/ 
22
Thank You! 
Questions? 
Abhinav Mehrotra 
Email: a.mehrotra@cs.bham.ac.uk 
GitHub: https://github.com/AbhinavMehrotra/SenSocial-Library 
SenSocial: http://www.cs.bham.ac.uk/~axm514/sensocial/ 
23

SenSocial

  • 1.
    SenSocial: A Middlewarefor Integrating Online Social Networks and Mobile Sensing Data Streams Abhinav Mehrotra, Veljko Pejovic, Mirco Musolesi School of Computer Science University of Birmingham
  • 2.
    Context-aware Systems PhysicalContext Mobile Sensors Emotional Context Social Context Online Social Networks 2
  • 3.
    Context-aware Systems Richer Contextual Information App 1 Real Time Integration How to integrate? Integration App 2 3
  • 4.
    Application Scenarios SensorData Social Links Sensor Data Notification Online Social Network Internet Server Notification Notice of friend’s arrival to Paris Sensor Data 4
  • 5.
    Application Scenarios Facebook’semotional contagion experiment, Kramer et al. (2014) EmotionSense, Rachuri et al. (2010) 5 How these can be improved ?
  • 6.
  • 7.
  • 8.
    Key Abstractions Application onDataSensed() Subscribe Context Data SenSocial subscribe() 8 Publish-Subscribe Interaction Paradigm Streams Stream Filters Stream Aggregators Multicast Multicast Streams
  • 9.
    Publish-Subscribe Interaction Paradigm Subscription Types - Topic-based (e.g., get user’s location). - Content-based (e.g., get user’s location when the user posts about football on his/her Facebook wall). Application onDataSensed() Subscribe subscribe() Context Data SenSocial 9
  • 10.
    Streams Types ofStream • Continuous (e.g., get user’s location when the user is not moving). • Social event-based (e.g., get user’s location when the user performs an action on Facebook). 10
  • 11.
    Stream Filters DataStreams Conditions A condition comprises of a modality, a comparison operator, and a value. Example: get location only when a user is not moving. Condition c = new Condition(ModalityType.physical_activity, Operator.equals, ModalityValue.still); Refined Information 11
  • 12.
    Stream Aggregator •It wraps multiple streams received by the server into a single aggregated stream. • Data from individual streams is multiplexed to the same join stream. • It works similarly to a normal stream. 12
  • 13.
    Multicast Stream Multicast • It creates duplicate streams on multiple clients. • Clients are selected based on the OSN connectivity and geographic location of the users. OSN Connectivity Geographic Location 13
  • 14.
    Other Features RemoteStream Management Streams can be created, modified, or destroyed remotely on the mobile clients. Privacy Control By specifying the allowed data type (context modality) and the level of granularity (raw or classified). 14
  • 15.
  • 16.
    Evaluation CPU consumptionwith varying number streams Average battery consumption with varying number of OSN actions OSN actions 1 2 3 4 5 6 7 Charge consumed [μAH] 51.7 97.1 142.5 187.8 233.2 278.5 324.3 Note: the above OSN actions occurred within 20 minute time period and each triggered remote sampling of all five supported sensor modalities. 16
  • 17.
    Prototype Applications FacebookSensor Map ConWeb 17
  • 18.
  • 19.
    Facebook Sensor Map:Code Snippet /*----------- Create streams----------------*/ SenSocialManager manager = SenSocialManager.getSenSocialManager(getApplicationContext()); String uid = manager.getUserId(); User user = manager.getUser(uid); Stream s1 = user.getDevice().getStream(SensorUtils.Sensor_Type_Accelerometer, "classified"); Stream s2 = user.getDevice().getStream(SensorUtils.Sensor_Type_Microphone, "classified"); Stream s3 = user.getDevice().getStream(SensorUtils.Sensor_Type_Location, "raw"); /*----------- Create list of filter condition(s) ----------------*/ ArrayList<Condition> conditions = new ArrayList<Condition>(); Condition c = new Condition(ModalityType.facebook_activity, Operator.equals, ModalityValue.active); conditions.add(c); /*----------- Add condition list to the filter -----------*/ Filter filter = new Filter(conditions); /*----------- Set filter to the streams -----------*/ s1 = s1.setFilter(filter); s2 = s2.setFilter(filter); s3 = s3.setFilter(filter); /*----------- Register streams -----------*/ manager.registerListener(this, stream1.getId()); manager.registerListener(this, stream2.getId()); manager.registerListener(this, stream3.getId()); /*----------- Start streams -----------*/ stream1.start(); stream2.start(); stream3.start(); 19
  • 20.
    Programming Effort Evaluation Facebook Sensor Map : lines of code reduced by nine times (from 3423 to 316). ConWeb : lines of code reduced by twenty four times (from 3223 to 130). Application Name Number of files Lines of code Facebook Sensor Map (M) (with SenSocial) 8 103 Facebook Sensor Map (S) (with SenSocial) 2 213 Facebook Sensor Map (M) (without SenSocial) 68 2419 Facebook Sensor Map (S) (without SenSocial) 42 1004 ConWeb (M) (with SenSocial) 3 23 ConWeb (S) (with SenSocial) 1 107 ConWeb (M) (without SenSocial) 61 2278 ConWeb (S) (without SenSocial) 38 945 20
  • 21.
    Summary • Weargue that the integration of OSNs and mobile sensor data streams can benefit in obtaining richer contextual information. • We propose SenSocial to simplify the implementation of such ubiquitous computing applications. • SenSocial is released as an open-source project. Available at: https://github.com/AbhinavMehrotra/SenSocial-Library 21
  • 22.
  • 23.
    Thank You! Questions? Abhinav Mehrotra Email: a.mehrotra@cs.bham.ac.uk GitHub: https://github.com/AbhinavMehrotra/SenSocial-Library SenSocial: http://www.cs.bham.ac.uk/~axm514/sensocial/ 23