Support
Quality
Security
License
Reuse
kandi has reviewed Java-WebSocket and discovered the below as its top functions. This is intended to give you an instant insight into Java-WebSocket implemented functionality, and help decide if they suit your requirements.
[RFC 6455](http://tools.ietf.org/html/rfc6455)
[RFC 7692](http://tools.ietf.org/html/rfc7692)
Dependency management tools
<dependency>
<groupId>org.java-websocket</groupId>
<artifactId>Java-WebSocket</artifactId>
<version>1.5.1</version>
</dependency>
Writing your own WebSocket Client
You can find a lot of examples [here](https://github.com/TooTallNate/Java-WebSocket/tree/master/src/main/example).
WSS Support
---------------------------------
This library supports wss.
To see how to use wss please take a look at the examples.<br>
If you do not have a valid **certificate** in place then you will have to create a self signed one.
Browsers will simply refuse the connection in case of a bad certificate and will not ask the user to accept it.
So the first step will be to make a browser to accept your self signed certificate. ( https://bugzilla.mozilla.org/show_bug.cgi?id=594502 ).<br>
If the websocket server url is `wss://localhost:8000` visit the url `https://localhost:8000` with your browser. The browser will recognize the handshake and allow you to accept the certificate.
The vm option `-Djavax.net.debug=all` can help to find out if there is a problem with the certificate.
It is currently not possible to accept ws and wss connections at the same time via the same websocket server instance.
For some reason Firefox does not allow multiple connections to the same wss server if the server uses a different port than the default port (443).
If you want to use `wss` on the android platform you should take a look at [this](https://github.com/TooTallNate/Java-WebSocket/wiki/FAQ:-Secure-WebSockets#wss-on-android).
I ( @Davidiusdadi ) would be glad if you would give some feedback whether wss is working fine for you or not.
Minimum Required JDK
--------------------
`Java-WebSocket` is known to work with:
* Java 1.7 and higher
Other JRE implementations may work as well, but haven't been tested.
License
-------
Everything found in this repo is licensed under an MIT license. See
the `LICENSE` file for specifics.
gRPC code not being generated from proto file
import com.google.protobuf.gradle.*
plugins {
java
idea
application
id("com.google.protobuf") version "0.8.14"
id("io.freefair.lombok") version "5.3.0"
}
repositories {
mavenCentral()
jcenter()
}
val grpcVersion = "1.34.1"
val protocVersion = "3.12.0"
val slf4jVersion = "1.7.25"
dependencies {
implementation("io.grpc:grpc-netty:${grpcVersion}")
implementation("io.grpc:grpc-protobuf:${grpcVersion}")
implementation("io.grpc:grpc-stub:${grpcVersion}")
implementation("org.slf4j:slf4j-api:${slf4jVersion}")
implementation("org.slf4j:slf4j-simple:${slf4jVersion}")
testImplementation("junit:junit:4.13")
}
// Look here for set path
sourceSets {
main {
proto {
srcDir("src/main/resources/proto")
}
}
}
protobuf {
protoc { artifact = "com.google.protobuf:protoc:${protocVersion}" }
plugins {
id("grpc") {
artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}"
}
}
generateProtoTasks {
ofSourceSet("main").forEach {
it.plugins {
id("grpc")
}
}
}
}
Toast Message is not created when message received at Java Websocket server in Android
new Handler(Looper.getMainLooper()).post(new Runnable() {
public void run() {
Toast.makeText(MainActivity.this, "Received: " + message, Toast.LENGTH_SHORT).show();
}
});
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(MainActivity.this, "Received: " + message, Toast.LENGTH_SHORT).show();
}
});
@Override
public void onMessage(WebSocket conn, String message) {
System.out.println("Recieved: "+message);
Intent intent = new Intent("msgReceived");
intent.putExtra("message", message);
LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
}
private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String message = intent.getExtras().getString("message");
Toast.makeText(MainActivity.this, "Received: " + message, Toast.LENGTH_SHORT).show();
}
};
@Override
protected void onStart() {
super.onStart();
LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver, new IntentFilter("msgReceived"));
@Override
protected void onStop() {
LocalBroadcastManager.getInstance(this).unregisterReceiver(mMessageReceiver);
super.onStop();
}
-----------------------
new Handler(Looper.getMainLooper()).post(new Runnable() {
public void run() {
Toast.makeText(MainActivity.this, "Received: " + message, Toast.LENGTH_SHORT).show();
}
});
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(MainActivity.this, "Received: " + message, Toast.LENGTH_SHORT).show();
}
});
@Override
public void onMessage(WebSocket conn, String message) {
System.out.println("Recieved: "+message);
Intent intent = new Intent("msgReceived");
intent.putExtra("message", message);
LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
}
private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String message = intent.getExtras().getString("message");
Toast.makeText(MainActivity.this, "Received: " + message, Toast.LENGTH_SHORT).show();
}
};
@Override
protected void onStart() {
super.onStart();
LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver, new IntentFilter("msgReceived"));
@Override
protected void onStop() {
LocalBroadcastManager.getInstance(this).unregisterReceiver(mMessageReceiver);
super.onStop();
}
-----------------------
new Handler(Looper.getMainLooper()).post(new Runnable() {
public void run() {
Toast.makeText(MainActivity.this, "Received: " + message, Toast.LENGTH_SHORT).show();
}
});
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(MainActivity.this, "Received: " + message, Toast.LENGTH_SHORT).show();
}
});
@Override
public void onMessage(WebSocket conn, String message) {
System.out.println("Recieved: "+message);
Intent intent = new Intent("msgReceived");
intent.putExtra("message", message);
LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
}
private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String message = intent.getExtras().getString("message");
Toast.makeText(MainActivity.this, "Received: " + message, Toast.LENGTH_SHORT).show();
}
};
@Override
protected void onStart() {
super.onStart();
LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver, new IntentFilter("msgReceived"));
@Override
protected void onStop() {
LocalBroadcastManager.getInstance(this).unregisterReceiver(mMessageReceiver);
super.onStop();
}
-----------------------
new Handler(Looper.getMainLooper()).post(new Runnable() {
public void run() {
Toast.makeText(MainActivity.this, "Received: " + message, Toast.LENGTH_SHORT).show();
}
});
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(MainActivity.this, "Received: " + message, Toast.LENGTH_SHORT).show();
}
});
@Override
public void onMessage(WebSocket conn, String message) {
System.out.println("Recieved: "+message);
Intent intent = new Intent("msgReceived");
intent.putExtra("message", message);
LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
}
private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String message = intent.getExtras().getString("message");
Toast.makeText(MainActivity.this, "Received: " + message, Toast.LENGTH_SHORT).show();
}
};
@Override
protected void onStart() {
super.onStart();
LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver, new IntentFilter("msgReceived"));
@Override
protected void onStop() {
LocalBroadcastManager.getInstance(this).unregisterReceiver(mMessageReceiver);
super.onStop();
}
Static interface methods are only supported starting with Android N (--min-api 24): void butterknife.Unbinder.lambda$static$0()
android {
...
// Butterknife requires Java 8.
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'com.jakewharton:butterknife:10.2.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1'
}
How to add external jars to Webots?
; runtime.ini for a Java controller on Windows
[environment variables with paths]
CLASSPATH = ../lib/MyLibrary.jar
JAVA_LIBRARY_PATH = ../lib
[java]
COMMAND = javaw.exe
OPTIONS = -Xms6144k
running a javax.websocket endpoint in spring?
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
@Configuration
@EnableWebSocket
public class WsConfig {
@Bean
public ServerEndpointExporter serverEndpoint() {
return new ServerEndpointExporter();
}
}
@ServerEndpoint(
value = "/chat/{username}",
decoders=MessageDecoder.class,
encoders = MessageEncoder.class
)
@Component
public class Controller {
...
-----------------------
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
@Configuration
@EnableWebSocket
public class WsConfig {
@Bean
public ServerEndpointExporter serverEndpoint() {
return new ServerEndpointExporter();
}
}
@ServerEndpoint(
value = "/chat/{username}",
decoders=MessageDecoder.class,
encoders = MessageEncoder.class
)
@Component
public class Controller {
...
-----------------------
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
@Configuration
@EnableWebSocket
public class WsConfig {
@Bean
public ServerEndpointExporter serverEndpoint() {
return new ServerEndpointExporter();
}
}
@ServerEndpoint(
value = "/chat/{username}",
decoders=MessageDecoder.class,
encoders = MessageEncoder.class
)
@Component
public class Controller {
...
Cannot connect to java websocket server
@Configuration
public class WebSocketConfig {
@Bean
public ServerEndpointExporter serverEndpointExporter() {
return new ServerEndpointExporter();
}
}
How to send an image from server to client with Web Socket using Java / Javascript?
for (String key : sMap.keySet())
{
Session s = sMap.get(key);
if (s.isOpen())
{
BufferedImage image = image_getter.getAnImage();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
// ImageIO.write(image,"jpg",baos);
ImageIO.write(image,"png",baos);
byte[] byteArray = baos.toByteArray();
s.getBasicRemote().sendObject(byteArray); // Works on both Swing & browser client
}
else sMap.remove(key);
}
this.webSocket.onmessage = function (event)
{
var msg = event.data;
console.log('onmessage :: ' + msg); // [object Blob]
var blobUrl = URL.createObjectURL(new Blob([msg]));
var image = new Image();
image.src = blobUrl;
// alert("blobUrl = "+blobUrl); // blob:http://localhost:8080/cc3751d6-5b49-462d-8a6f-f2221c899abf
image.onload = function() { context.drawImage(image, 0, 0); };
};
@OnWebSocketMessage
public void onMessage(InputStream is)
{
try
{
if (imageLabel!=null)
{
BufferedImage img = ImageIO.read(is);
imageLabel.setIcon(new ImageIcon(img));
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
-----------------------
for (String key : sMap.keySet())
{
Session s = sMap.get(key);
if (s.isOpen())
{
BufferedImage image = image_getter.getAnImage();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
// ImageIO.write(image,"jpg",baos);
ImageIO.write(image,"png",baos);
byte[] byteArray = baos.toByteArray();
s.getBasicRemote().sendObject(byteArray); // Works on both Swing & browser client
}
else sMap.remove(key);
}
this.webSocket.onmessage = function (event)
{
var msg = event.data;
console.log('onmessage :: ' + msg); // [object Blob]
var blobUrl = URL.createObjectURL(new Blob([msg]));
var image = new Image();
image.src = blobUrl;
// alert("blobUrl = "+blobUrl); // blob:http://localhost:8080/cc3751d6-5b49-462d-8a6f-f2221c899abf
image.onload = function() { context.drawImage(image, 0, 0); };
};
@OnWebSocketMessage
public void onMessage(InputStream is)
{
try
{
if (imageLabel!=null)
{
BufferedImage img = ImageIO.read(is);
imageLabel.setIcon(new ImageIcon(img));
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
-----------------------
for (String key : sMap.keySet())
{
Session s = sMap.get(key);
if (s.isOpen())
{
BufferedImage image = image_getter.getAnImage();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
// ImageIO.write(image,"jpg",baos);
ImageIO.write(image,"png",baos);
byte[] byteArray = baos.toByteArray();
s.getBasicRemote().sendObject(byteArray); // Works on both Swing & browser client
}
else sMap.remove(key);
}
this.webSocket.onmessage = function (event)
{
var msg = event.data;
console.log('onmessage :: ' + msg); // [object Blob]
var blobUrl = URL.createObjectURL(new Blob([msg]));
var image = new Image();
image.src = blobUrl;
// alert("blobUrl = "+blobUrl); // blob:http://localhost:8080/cc3751d6-5b49-462d-8a6f-f2221c899abf
image.onload = function() { context.drawImage(image, 0, 0); };
};
@OnWebSocketMessage
public void onMessage(InputStream is)
{
try
{
if (imageLabel!=null)
{
BufferedImage img = ImageIO.read(is);
imageLabel.setIcon(new ImageIcon(img));
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
QUESTION
Notification from Google Play || Malicious Behavior or User Data policy || Intent Redirection
Asked 2021-Apr-22 at 07:48As mentioned in image my app is violating there policy but i've another app for the same which is for doctor's and that app is using the same libraries and almost everything similar to this app but still my doctor app is accepted without any violation
androidx.fragment.app.FragmentActivity.startActivityForResult and they are saying your startActivityForResult is responsible for this but i'm only calling this line for opening camera and gallery.
i've tried uploading my app multiple time's with upgraded gradle and there remediations available here https://support.google.com/faqs/answer/9267555 but still no success.
you can also refer below image for further details.
my gradle
buildscript {
repositories {
maven { url 'https://plugins.gradle.org/m2/' }
}
dependencies {
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.12.8'
}
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
repositories {
maven { url 'https://maven.google.com' }
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.firebase.crashlytics'
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.doctoronline.telehealth.patient"
manifestPlaceholders = [
onesignal_app_id : "********-****-****-****-************",
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: "REMOTE"
]
minSdkVersion 21
targetSdkVersion 29
versionCode 44
versionName "1.0.24.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildFeatures {
viewBinding = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
checkReleaseBuilds false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
kotlinOptions {
jvmTarget = '1.8'
}
}
}
buildscript {
repositories {
mavenCentral()
google()
}
dependencies {
//noinspection GradlePluginVersion
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
repositories {
mavenCentral()
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'de.hdodenhof:circleimageview:3.1.0'
implementation 'org.java-websocket:Java-WebSocket:1.3.9'
implementation 'com.android.volley:volley:1.1.1'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.google.firebase:firebase-core:18.0.1'
implementation 'org.webrtc:google-webrtc:1.0.28513'
implementation 'com.payumoney.sdkui:plug-n-play:1.6.0'
implementation 'com.google.firebase:firebase-analytics:18.0.1'
implementation 'com.google.firebase:firebase-crashlytics:17.3.0'
implementation 'com.flurry.android:analytics:11.6.0@aar'
implementation 'com.github.bumptech.glide:glide:4.9.0'
implementation('com.alimuzaffar.lib:pinentryedittext:1.3.10')
implementation 'com.hbb20:ccp:2.3.2'
implementation 'com.google.android.gms:play-services-auth:19.0.0'
implementation 'com.google.android.gms:play-services-auth-api-phone:17.5.0'
implementation 'com.koushikdutta.ion:ion:3.0.8'
implementation 'com.wdullaer:materialdatetimepicker:4.2.3'
implementation 'io.agora.rtc:full-sdk:3.0.0'
api 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
//OneSignal
implementation 'com.onesignal:OneSignal:3.14.1'
implementation 'com.toptoche.searchablespinner:searchablespinnerlibrary:1.3.1'
//Auto-Resizable Pixel
implementation 'com.intuit.sdp:sdp-android:1.0.6'
implementation 'com.intuit.ssp:ssp-android:1.0.6'
//for new version updater
implementation 'com.google.android.play:core:1.9.1'
}
apply plugin: 'com.google.gms.google-services'
ANSWER
Answered 2021-Mar-23 at 06:26In my case it was sms broadcast receiver, heres mail received from google after around a month of coordination with google play team they sent mw the details of the violation please take a look at the image attached below.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
No vulnerabilities reported
Save this library and start creating your kit
Explore Related Topics
Save this library and start creating your kit