use of org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.ByteString in project java-tron by tronprotocol.
the class AccountCapsuleTest method init.
@BeforeClass
public static void init() {
Args.setParam(new String[] { "-d", dbPath, "-w" }, Configuration.getByPath(Constant.TEST_CONF));
ByteString accountName = ByteString.copyFrom(AccountCapsuleTest.randomBytes(16));
ByteString address = ByteString.copyFrom(AccountCapsuleTest.randomBytes(32));
AccountType accountType = AccountType.forNumber(1);
accountCapsuleTest = new AccountCapsule(accountName, address, accountType);
byte[] accountByte = accountCapsuleTest.getData();
accountCapsule = new AccountCapsule(accountByte);
accountCapsuleTest.setBalance(1111L);
}
use of org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.ByteString in project java-tron by tronprotocol.
the class AccountTest method getAccountName.
@Test
public void getAccountName() {
byte[] bytes = ByteArray.fromString("tron");
if (ArrayUtils.isNotEmpty(bytes)) {
ByteString accountName = ByteString.copyFrom(bytes);
Assert.assertEquals(accountName, account.getAccountName());
}
}
use of org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.ByteString in project java-tron by tronprotocol.
the class AccountTest method setAccountNameRight.
@Test
public void setAccountNameRight() {
account.setAccountName("tron-name");
byte[] bytes = ByteArray.fromString("tron-name");
if (ArrayUtils.isNotEmpty(bytes)) {
ByteString accountName = ByteString.copyFrom(bytes);
Assert.assertEquals(accountName, account.getAccountName());
}
}
use of org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.ByteString in project openzaly by akaxincom.
the class U2MessageTextHandler method handle.
public Boolean handle(Command command) {
try {
ImCtsMessageProto.ImCtsMessageRequest request = ImCtsMessageProto.ImCtsMessageRequest.parseFrom(command.getParams());
int type = request.getType().getNumber();
if (CoreProto.MsgType.TEXT_VALUE == type) {
String siteUserId = command.getSiteUserId();
String siteFriendId = request.getText().getSiteFriendId();
String msgId = request.getText().getMsgId();
ByteString byteStr = request.getText().getText();
String msgText = byteStr.toString(Charset.forName("UTF-8"));
command.setSiteFriendId(siteFriendId);
long msgTime = System.currentTimeMillis();
U2MessageBean u2Bean = new U2MessageBean();
u2Bean.setMsgId(msgId);
u2Bean.setMsgType(type);
u2Bean.setSendUserId(siteUserId);
u2Bean.setSiteUserId(siteFriendId);
u2Bean.setContent(msgText);
u2Bean.setMsgTime(msgTime);
LogUtils.requestDebugLog(logger, command, u2Bean.toString());
boolean success = messageDao.saveU2Message(u2Bean);
msgStatusResponse(command, msgId, msgTime, success);
return success;
}
return true;
} catch (Exception e) {
LogUtils.requestErrorLog(logger, command, this.getClass(), e);
}
return false;
}
use of org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.ByteString in project openzaly by akaxincom.
the class U2MessageTextSecretHandler method handle.
public Boolean handle(Command command) {
ChannelSession channelSession = command.getChannelSession();
try {
ImCtsMessageProto.ImCtsMessageRequest request = ImCtsMessageProto.ImCtsMessageRequest.parseFrom(command.getParams());
int type = request.getType().getNumber();
if (CoreProto.MsgType.SECRET_TEXT_VALUE == type) {
String siteUserId = command.getSiteUserId();
String siteFriendId = command.getSiteFriendId();
String msgId = request.getSecretText().getMsgId();
String tsKey = request.getSecretText().getTsKey();
String tsDeviceId = request.getSecretText().getSiteDeviceId();
ByteString byteStr = request.getSecretText().getText();
String msgText = Base64.getEncoder().encodeToString(byteStr.toByteArray());
long msgTime = System.currentTimeMillis();
U2MessageBean u2Bean = new U2MessageBean();
u2Bean.setMsgId(msgId);
u2Bean.setMsgType(type);
u2Bean.setSendUserId(siteUserId);
u2Bean.setSiteUserId(siteFriendId);
u2Bean.setContent(msgText);
u2Bean.setTsKey(tsKey);
u2Bean.setDeviceId(tsDeviceId);
u2Bean.setMsgTime(msgTime);
LogUtils.requestDebugLog(logger, command, u2Bean.toString());
boolean success = messageDao.saveU2Message(u2Bean);
msgStatusResponse(command, msgId, msgTime, success);
return success;
}
return true;
} catch (Exception e) {
LogUtils.requestErrorLog(logger, command, this.getClass(), e);
}
return false;
}
Aggregations